-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathapp.py
84 lines (67 loc) · 1.94 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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#importing files
from flask import Flask,render_template,request,redirect,url_for,send_from_directory,jsonify,abort
import os
import imgkit
import secondyear
import thirdyear
import firstyear
import fourthyear
#app name
app=Flask(__name__)
#app route for main page
@app.route('/', methods=['GET', 'POST'])
def home():
#deleting all file in the folder
# folder = 'static/temp/'
# for the_file in os.listdir(folder):
# file_path = os.path.join(folder, the_file)
# try:
# if os.path.isfile(file_path):
# os.unlink(file_path)
# except Exception as e:
# print(e)
if request.method == 'GET':
return render_template("index.html")
elif request.method == 'POST':
year=int(request.form.get('year'))
batch=request.form.get('batch').upper()
#returning dictionary from module
if year==2:
tt_dict=secondyear.second(batch)
elif year==3:
tt_dict=thirdyear.third(batch)
elif year==1:
tt_dict=firstyear.first(batch)
elif year==4:
tt_dict=fourthyear.fourth(batch)
try:
pass
except Exception as e:
return render_template("timetable.html",tt_dict=tt_dict)
return render_template("timetable.html",tt_dict=tt_dict)
@app.route('/tt/<int:year>/<batch>', methods=['GET'])
def tt(year,batch):
batch=batch.upper()
if year==2:
tt_dict=secondyear.second(batch)
elif year==3:
tt_dict=thirdyear.third(batch)
elif year==1:
tt_dict=firstyear.first(batch)
elif year==4:
tt_dict=fourthyear.fourth(batch)
return render_template("timetable.html",tt_dict=tt_dict)
@app.route('/api/<int:year>/<batch>', methods=['GET'])
def api(year,batch):
batch=batch.upper()
if year==2:
tt_dict=secondyear.second(batch)
elif year==3:
tt_dict=thirdyear.third(batch)
elif year==1:
tt_dict=firstyear.first(batch)
elif year==4:
tt_dict=fourthyear.fourth(batch)
return jsonify(tt_dict)
if(__name__=='__main__'):
app.run(debug=True,use_reloader=True)