-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
67 lines (57 loc) · 1.9 KB
/
main.py
File metadata and controls
67 lines (57 loc) · 1.9 KB
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
from flask import Flask, abort, jsonify, request, render_template
import joblib
from feature import *
from scraping import *
import json
from flask_cors import CORS, cross_origin
pipeline = joblib.load('pipeline.sav')
app = Flask(__name__)
cors = CORS(app)
app.config['CORS_HEADERS'] = 'Content-Type'
# @app.route('/')
# def home():
# return render_template('index.html')
# @app.route('/api',methods=['POST'])
# def get_delay():
# result = request.get_json()
# query_title = result['title']
# query_text = result['maintext']
# query_author = " "
# query = get_all_query(query_title, query_author , query_text)
# user_input = {'query':query}
# pred = pipeline.predict(query)
# dic = {1:'real',0:'fake'}
# return jsonify(dic[pred[0]])
# @app.route('/api',methods=['GET'])
# @cross_origin()
# def get_url():
# result=request.args.get("link")
# url = result
# query_text = scrap_url(url)
# query = get_all_query(query_text)
# pred = pipeline.predict(query)
# dic = {1:'real',0:'fake'}
# return jsonify(dic[pred[0]])
@app.route('/api', methods=['GET', 'POST'])
@cross_origin()
def register():
if request.method == 'POST':
result = request.get_json()
query_title = result['title']
query_text = result['maintext']
query_author = " "
query = get_all_query(query_title, query_author , query_text)
user_input = {'query':query}
pred = pipeline.predict(query)
dic = {1:'real',0:'fake'}
return jsonify(res=dic[pred[0]])
else:
result=request.args.get("link")
url = result
query_text = scrap_url(url)
query = get_all_query(query_text)
pred = pipeline.predict(query)
dic = {1:'real',0:'fake'}
return jsonify(res=dic[pred[0]])
if __name__ == '__main__':
app.run(debug=True)