-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathapp.py
More file actions
33 lines (23 loc) · 729 Bytes
/
app.py
File metadata and controls
33 lines (23 loc) · 729 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
32
33
from flask import Flask, render_template, jsonify
from hansard.parsing import HansardParser
import os
app = Flask(__name__)
HANSARD_DATA = "sample.xml"
@app.route("/markovstuff")
def get_markov():
markov_stuff = HansardParser().parse(HANSARD_DATA)
json_dict = []
for i in markov_stuff:
if i.content.strip():
tmp = {}
tmp["type"] = i.type
tmp["content"] = i.content
tmp["politician_id"] = i.state.politician_id
json_dict.append(tmp)
return jsonify(json_dict)
@app.route("/")
def index():
return render_template("index.html")
if __name__ == "__main__":
port = int(os.environ.get('PORT', 5000))
app.run(debug=True, port=port)