-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathapp.py
30 lines (22 loc) · 803 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
import os
from final_project import create_result
from flask import Flask, render_template, request, jsonify, url_for
app = Flask(__name__)
UPLOAD_FOLDER = os.path.basename('data')
app.config['UPLOAD_FOLDER'] = UPLOAD_FOLDER
@app.route('/')
def hello_world():
return render_template('index.html')
@app.route('/upload', methods=['POST'])
def upload_file():
file = request.files['image']
f = os.path.join(app.config['UPLOAD_FOLDER'], "demo.png")
# add your custom code to check that the uploaded file is a valid image and not a malicious file (out-of-scope for this post)
file.save(f)
data = {
'status': 'success',
'result': create_result()
}
return render_template('index.html', data=data)
if __name__ == "__main__":
app.run(port=8080)