-
Notifications
You must be signed in to change notification settings - Fork 2
/
app.py
28 lines (20 loc) · 774 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
from flask import Flask, render_template, request
import os
from deeplearning import OCR
from yolo_prediction import object_detection
# webserver gateway interface
app = Flask(__name__)
BASE_PATH = os.getcwd()
UPLOAD_PATH = os.path.join(BASE_PATH,'static/upload/')
@app.route('/',methods=['POST','GET'])
def index():
if request.method == 'POST':
upload_file = request.files['image_name']
filename = upload_file.filename
path_save = os.path.join(UPLOAD_PATH,filename)
upload_file.save(path_save)
text = OCR(path_save, filename)
return render_template("index.html", upload=True, upload_image=filename, text=text)
return render_template('index.html',upload=False)
if __name__ =="__main__":
app.run(debug=True)