-
Notifications
You must be signed in to change notification settings - Fork 0
/
deploy.py
39 lines (30 loc) · 943 Bytes
/
deploy.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
from flask import Flask, render_template, request,send_from_directory,redirect,url_for
import os
from werkzeug import secure_filename
from code import process
up = 'up/'
down = 'down/'
app = Flask(__name__,template_folder = 'static/')
app.static_folder = 'static/'
@app.route('/')
def feed():
return redirect(url_for('upload'))
@app.route('/upload')
def upload():
return render_template('index.html')
@app.route('/uploader', methods = ['GET', 'POST'])
def upload_file():
if request.method == 'POST':
f = request.files['file']
global fname
fname = f.filename
f.save(os.path.join(up,secure_filename(f.filename)))
path = os.path.join(up,fname)
process(path,down)
return redirect(url_for('fetch'))
@app.route('/fetch')
def fetch():
fname = 'output.csv'
return send_from_directory(directory = down,filename = fname,mimetype = 'text/csv')
if __name__ == '__main__':
app.run()