-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathapp.py
50 lines (36 loc) · 1.39 KB
/
app.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
46
47
48
49
50
import os
from flask import Flask, abort
from flask import render_template
from flask import request
from flask_misaka import Misaka
from flask_pymongo import PyMongo
from methods import comment_history, recreate_body_diffs, parse_identifier
app = Flask(__name__)
app.config['MONGO_URI'] = 'mongodb://steemit:[email protected]:27017/SteemData'
mongo = PyMongo(app)
# enable markdown rendering
md_features = ['autolink', 'fenced_code', 'underline', 'highlight', 'quote',
'math', 'superscript', 'tables', 'wrap']
md_features = {x: True for x in md_features}
Misaka(app, **md_features)
@app.route('/')
def hello_world():
return render_template('index.html')
@app.route('/history', methods=['GET'])
def history():
identifier_uri = request.args.get('identifier')
app.logger.info(identifier_uri)
comments = comment_history(mongo.db, identifier_uri)
if not comments:
abort(404)
original, diffs = recreate_body_diffs(comments)
return render_template('history.html',
identifier=parse_identifier(identifier_uri),
original=original,
diffs=diffs)
@app.errorhandler(404)
def page_not_found(error):
return render_template('404.html'), 404
if __name__ == '__main__':
app.run(host=os.getenv('FLASK_HOST', '127.0.0.1'),
debug=not os.getenv('PRODUCTION', False))