-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.py
More file actions
53 lines (34 loc) · 1014 Bytes
/
app.py
File metadata and controls
53 lines (34 loc) · 1014 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
41
42
43
44
45
46
47
48
49
50
51
52
53
from flask import Flask, render_template, jsonify, request, make_response
import json
import requests
from time import sleep
from flask_apscheduler import APScheduler
from random import randint
from datetime import datetime
class Config:
SCHEDULER_API_ENABLED = True
app = Flask(__name__)
app.config.from_object(Config())
scheduler = APScheduler()
scheduler.init_app(app)
global data
global timestamp
global x_range
global growth_rate
global data_usd
data = [1]
timestamp = [datetime.now().strftime("%H:%M")]
@scheduler.task('interval', id='update_data', seconds=1)
def update_data():
data.append(data[-1]+1)
current_time = datetime.now().strftime("%H:%M")
timestamp.append(current_time)
scheduler.start()
@app.route('/')
def index():
return render_template("index.html")
@app.route('/update_plot', methods=['POST', 'GET'])
def update_plot():
return jsonify(timestamp=timestamp, data=data)
if __name__ == "__main__":
app.run(host='127.0.0.1', port=48000, debug=True)