-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathserver.py
More file actions
36 lines (31 loc) · 841 Bytes
/
server.py
File metadata and controls
36 lines (31 loc) · 841 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
34
35
36
from flask import Flask, jsonify
from flask_cors import CORS, cross_origin
import master
import articlesearch as AS
app = Flask(__name__)
cors = CORS(app)
app.config['CORS_HEADERS'] = 'Content-Type'
@app.route("/wiki/<source>/<target>")
@cross_origin()
def wiki(source, target):
res = master.main(source, target)
print("wiki: " + str(res))
return jsonify(**res)
@app.route("/views/")
@cross_origin()
def views():
res = {}
res["hillary"] = hillaryViews()
res["trump"] = trumpViews()
print("views: " + str(res))
return jsonify(**res)
@app.route("/articles/<source>")
@cross_origin()
def articles(source):
res = {}
res["hillary"] = hillaryArticles(source)
res["trump"] = trumpArticles(source)
print("articles: " + str(res))
return jsonify(**res)
if __name__ == "__main__":
app.run()