-
Notifications
You must be signed in to change notification settings - Fork 2
/
app.py
51 lines (34 loc) · 1.14 KB
/
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
41
42
43
44
45
46
47
48
49
50
51
from flask import Flask, render_template, request, send_file, url_for
from werkzeug.utils import secure_filename
import os
from functions import *
app = Flask(__name__)
@app.route('/')
@app.route('/home')
def home():
return render_template('index.html', methods = ['GET', 'POSTS'])
@app.route('/about')
def about():
return render_template('about.html')
@app.route('/stylize')
def to_upload_page():
return render_template('stylize.html')
@app.route('/uploader', methods=['POST'])
def file_upload():
content, style = 'content', 'style'
content_file = request.files['contentFile']
style_file = request.files['styleFile']
if content_file and style_file:
try:
content_file.save('static/' + content + '.jpg')
style_file.save('static/' + style + '.jpg')
transformed = model(content, style)
fname = transformed + '.jpg'
except:
fname = 'error.jpg'
delete_files()
return render_template('result.html', filename=fname)
else:
return render_template('stylize.html')
if __name__ == "__main__":
app.run(debug=True)