-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrender.py
More file actions
31 lines (24 loc) · 913 Bytes
/
render.py
File metadata and controls
31 lines (24 loc) · 913 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
from flask import render_template, send_from_directory
import flask, os, json
from datetime import datetime
app = flask.Flask(__name__)
# Serve locally for debugging
@app.route('/')
def home():
with open(os.path.join('temp', 'dashInfo.json'), 'r') as file:
dashInfo = json.load(file)
return render_template('landing.html', dashInfo=dashInfo)
@app.route('/temp/<path:filename>')
def serveTemp(filename):
return send_from_directory('temp', filename)
@app.template_filter('timestampToDate')
def timestampToDate(timestamp):
return datetime.fromtimestamp(timestamp/1000).strftime("%d %b %Y, %H:%M")
if __name__ == "__main__":
app.debug = True
app.run(port=8080)
# with app.app_context():
# rendered = render_template('blog.html', \
# title = "My Generated Page", \
# people = [{"name": "Mark"}, {"name": "Michael"}])
# print(rendered)