forked from phoemur/fundamentus
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.py
executable file
·45 lines (32 loc) · 1 KB
/
server.py
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
#!/usr/bin/env python3
from flask import Flask, jsonify
from fundamentus import get_data
from datetime import datetime
import json
from vanish.main import vanishData
app = Flask(__name__)
# First update
lista, dia = dict(get_data()), datetime.strftime(datetime.today(), '%d')
@app.route("/original")
def original():
global lista, dia
# Then only update once a day
if dia == datetime.strftime(datetime.today(), '%d'):
return jsonify(lista)
else:
lista, dia = dict(get_data()), datetime.strftime(datetime.today(), '%d')
return jsonify(lista)
@app.route("/tabela")
def table():
global lista, dia
# Then only update once a day
if dia == datetime.strftime(datetime.today(), '%d'):
data = json.dumps(lista)
data = vanishData(data)
return data
else:
lista, dia = dict(get_data()), datetime.strftime(datetime.today(), '%d')
data = json.dumps(lista)
data = vanishData(data)
return data
app.run(debug=True)