-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
28 lines (21 loc) · 795 Bytes
/
main.py
File metadata and controls
28 lines (21 loc) · 795 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
from flask import Flask, send_from_directory
from random import randint
from os import getenv
app = Flask(__name__)
@app.route("/api/quote")
def index():
with open('quotes.txt') as f:
quotes = [line.rstrip() for line in f]
with open('authors.txt') as f:
authors = [line.rstrip() for line in f]
random_index = randint(0, len(quotes))
return "{\"quote\": \"" + quotes[random_index] + "\", " \
"\"author\": \"" + authors[random_index] + "\", " \
"\"appVersion\": \"1.0.0\", " \
"\"environmentName\": \"" + getenv('ENVIRONMENT_NAME', 'Local') + "\" " \
"}"
@app.route('/<path:path>')
def send_js(path):
return send_from_directory('public', path)
if __name__ == "__main__":
app.run(host="0.0.0.0", port=8080, debug=True)