-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.py
42 lines (33 loc) · 1.45 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
""" web app for the fake news detector"""
from flask import Flask, render_template
from flask import request
import prediction as detc #import all objects from detector.py
app = Flask(__name__) #tell Flask to make THIS script the center of the application
#whenever user visits HOSTNAME:PORT/index, this function is triggered
@app.route('/index', methods=['POST', 'GET'])
@app.route('/')
def index():
#user_input = str(request.form)
return render_template('index.html')
#python decorater modifies the function that is defined on the next line.
@app.route('/result', methods=['GET', 'POST'])
def detector():
user_input = request.args.get('user_input')
print(user_input)
result = detc.detecting_fake_news(user_input)
return render_template('result.html', result=result)
@app.route('/about')
def about():
#user_input = str(request.form)
return render_template('about.html')
@app.route('/info')
def info():
#user_input = str(request.form)
return render_template('info.html')
if __name__ == '__main__':
#whatever occurs after this line is executed when we run "python application.py"
#however, whatever occurs after this line is NOT executed when we IMPORT application.py
app.run(debug=True) #this will start an infinite process, i.e. serving our web page.
#debug mode displays backend errors to the browser
#(good for development but bad idea for production).
#Also automatically restarts server upon changes to code.