-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.py
More file actions
37 lines (27 loc) · 792 Bytes
/
app.py
File metadata and controls
37 lines (27 loc) · 792 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
37
from __future__ import print_function
import sys
import os
import glob
import re
from flask import Flask, redirect, url_for, request, render_template
from werkzeug.utils import secure_filename
from model import get_pred, clear_uploads
app = Flask(__name__)
@app.route('/', methods=['GET'])
def index():
# Main page
return render_template('index.html')
@app.route('/predict', methods=['GET', 'POST'])
def upload():
if request.method == 'POST':
# Get the file from post request
f = request.files['file']
basepath = "uploads"
file_path = basepath + "/" + f.filename
f.save(file_path)
result = get_pred(file_path)
clear_uploads(file_path)
return result
return None
if __name__ == '__main__':
app.run()