-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.py
42 lines (22 loc) · 870 Bytes
/
server.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
from fake_news.preprocessor.error_handle import line_loc,highlight_back
from abstractor2 import with_keywords,without_keywords
from flask import Flask , jsonify,request
API_KEY =""
if(len(API_KEY)<=1):
highlight_back("ENTER YOUR API KEY ABOVE ON LINE 6 OF THIS FILE","R")
line_loc()
app = Flask(__name__)
@app.route('/api/without',methods=['GET','POST'])
def without_k():
if(request.method =='POST'):
url = request.get_json()['users_link']
return jsonify(without_keywords(url,API_KEY))
@app.route('/api/with',methods=['GET', 'POST'])
def with_k():
if(request.method == 'POST'):
url_and_keywords = request.get_json()
url = url_and_keywords['users_link']
keywords = url_and_keywords['keywords']
return jsonify(with_keywords(url,keywords,API_KEY))
if (__name__ =="__main__"):
app.run()