-
Notifications
You must be signed in to change notification settings - Fork 43
/
app.py
24 lines (17 loc) · 642 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
from flask import Flask, render_template, flash
from flask_wtf import Form
from flask_wtf.file import FileField
from tools import s3_upload
app = Flask(__name__)
app.config.from_object('config')
class UploadForm(Form):
example = FileField('Example File')
@app.route('/', methods=['POST', 'GET'])
def upload_page():
form = UploadForm()
if form.validate_on_submit():
output = s3_upload(form.example)
flash('{src} uploaded to S3 as {dst}'.format(src=form.example.data.filename, dst=output))
return render_template('example.html', form=form)
if __name__ == '__main__':
app.run()