-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathapp.py
38 lines (33 loc) · 1.18 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
#the import statement above decides which file gets the syllabus
import os
import sys
import tabula
from os import listdir
from docx import Document
#sys.path.append(os.path.abspath("backend"))
import SyllabusStripper
from flask import Flask, render_template, request, redirect, send_from_directory, send_file
app = Flask(__name__)
@app.route('/')
def home():
return render_template('index.html')
@app.route('/upload', methods=['POST'])
def upload_file():
if request.method == 'POST':
f = request.files['file']
filename = f.filename
if filename[filename.index("."):] == ".pdf":
f.save('uploaded_file.pdf')
if filename[filename.index("."):] == ".doc":
f.save('uploaded_file.doc')
if filename[filename.index("."):] == ".docx":
f.save('uploaded_file.docx')
#os.system("python ./backend/SyllabusStripper.py")
SyllabusStripper.main()
#exec(open("backend/SyllabusStripper.py").read())
return send_file('download.ics')
@app.route('/upload/uploaded_file')
def uploaded_file(f):
return send_from_directory(app.config['download.ics'], f, as_attachment=True)
if __name__ == '__main__':
app.run(debug=True)