-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.py
More file actions
40 lines (30 loc) · 731 Bytes
/
app.py
File metadata and controls
40 lines (30 loc) · 731 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
from flask import Flask, render_template
import sqlite3
import json
import time
class DB:
db = None
def __init__(self):
self.db = sqlite3.connect(
'db.sqlite3',
check_same_thread=False)
self.db.row_factory = sqlite3.Row
def sql(self, query):
cur = self.db.cursor()
cur.execute(query)
return cur.fetchall()
db = DB()
app = Flask('MyApp')
@app.route('/json')
def return_data():
td = []
rows = db.sql("Select Group_Number as col1 FROM Group_")
for r in rows:
td.append(dict(r))
print(json.dumps(td))
time.sleep(15)
return json.dumps(td)
@app.route('/')
def index():
return render_template('index.html')
app.run()