-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathapp.py
44 lines (38 loc) · 1.4 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
# Main Flask App File
from flask import *
from excel2table import write2text
from table2excel import writetoexcel
from excel2table2 import write2textSingle
app = Flask(__name__)
@app.route('/')
def upload():
return render_template("file_upload_form.html")
@app.route('/sitemap.xml')
def static_from_root():
return send_from_directory(app.static_folder, request.path[1:])
@app.route('/success', methods = ['POST'])
def success():
if request.method == 'POST':
f = request.files['file']
f.save(f.filename)
write2text(f.filename)
return render_template("success.html", filename='output.txt')
@app.route('/success2', methods = ['POST'])
def success2():
if request.method == 'POST':
f = request.files['file']
f.save(f.filename)
writetoexcel(f.filename)
return render_template("success2.html", filename='output.xls')
@app.route('/success3', methods = ['POST'])
def success3():
if request.method == 'POST':
f = request.files['file']
f.save(f.filename)
write2textSingle(f.filename)
return render_template("success3.html", filename='output.txt')
@app.route('/database_download/<filename>')
def database_download(filename):
return send_file(filename, as_attachment=True)
if __name__ == '__main__':
app.run(debug = True)