-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.py
More file actions
57 lines (44 loc) · 1.23 KB
/
server.py
File metadata and controls
57 lines (44 loc) · 1.23 KB
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
54
55
56
57
import os
from flask import Flask
from flask import jsonify
from flask import render_template
from dotenv import load_dotenv
import apis
app = Flask(__name__)
load_dotenv('config.env')
@app.route('/api/birthdays')
def birthdays():
return jsonify(apis.birthdays())
@app.route('/api/birthdays/now')
def birthdays_now():
return jsonify(apis.birthdays(only_this_month=True))
@app.route('/api/bitcoin')
def bitcoin():
return jsonify(apis.bitcoin())
@app.route('/api/weather')
def weather():
return jsonify(apis.weather())
@app.route('/api/covid')
def covid():
return jsonify(apis.covid())
@app.route('/api/chess')
def chess():
return jsonify(apis.chess())
@app.route('/api/trivia')
def trivia():
return jsonify(apis.trivia())
@app.route('/')
def index():
return render_template('index.html')
if os.getenv('DEBUG') == '1':
extra_dirs = ['static',]
extra_files = extra_dirs[:]
for extra_dir in extra_dirs:
for dirname, dirs, files in os.walk(extra_dir):
for filename in files:
filename = os.path.join(dirname, filename)
if os.path.isfile(filename):
extra_files.append(filename)
app.run(extra_files=extra_files)
else:
app.run()