-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathapp.py
40 lines (28 loc) · 958 Bytes
/
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
from flask import Flask, render_template,request, redirect, url_for
import os
from werkzeug.utils import secure_filename
from PIL import Image, ImageFile
import tensorflow as tf
import numpy as np
from func import reading
app = Flask(__name__)
@app.route('/', methods=['GET'])
def hello(name=None):
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']
# Save the file to ./uploads
basepath = os.path.dirname(__file__)
file_path = os.path.join(
basepath, 'uploads', secure_filename(f.filename))
f.save(file_path)
name="uploads/"+f.filename
prediction=reading(name)
text = "Prediction : "+prediction
return text
if __name__ =='__main__':
#app.debug = True
app.run(debug = True)