-
Notifications
You must be signed in to change notification settings - Fork 0
/
app2.py
24 lines (21 loc) · 882 Bytes
/
app2.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
import flask
import pandas as pd
import pickle
# Use pickle to load in the pre-trained model.
with open(f'model/final_model.pkl', 'rb') as f:
model = pickle.load(f)
app = flask.Flask(__name__, template_folder='templates')
@app.route('/', methods=['GET', 'POST'])
def main():
if flask.request.method == 'GET':
return(flask.render_template('main.html'))
if flask.request.method == 'POST':
url = flask.request.form['url']
input_variables = pd.DataFrame([[url]],
columns=['url'],
dtype='|S6')
prediction = model.predict(input_variables)[0]
return flask.render_template('main.html',
original_input={'url':url },
result=prediction,
)