-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathapp.py
264 lines (190 loc) · 6.58 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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
from flask import Flask, render_template, request, Response,send_file,send_from_directory,redirect, url_for
from flask_sqlalchemy import SQLAlchemy
from datetime import datetime
import os
from werkzeug.utils import secure_filename
from itertools import groupby
from model import Resources,app,db,Comment,Faculty,Event,Internship,Conference,Thesis
from flask_mail import Mail, Message
import view
import model
#create a .env.local named file
# Inside .env file
# MAIL_SERVER=smtp.example.com
# MAIL_PORT=587
# MAIL_USERNAME=your_email@example.com
# MAIL_PASSWORD=your_password
# MAIL_USE_TLS=Trues
# MAIL_USE_SSL=False
#Follow THis Instructions for Creating Password to access from mail
# Create & use app passwords
# Important: To create an app password, you need 2-Step Verification on your Google Account.
# If you use 2-Step-Verification and get a "password incorrect" error when you sign in, you can try to use an app password.
# Go to your Google Account.
# Select Security.
# Under "Signing in to Google," select 2-Step Verification.
# At the bottom of the page, select App passwords.
# Enter a name that helps you remember where you’ll use the app password.
# Select Generate.
# To enter the app password, follow the instructions on your screen. The app password is the 16-character code that generates on your device.
# Select Done.
app.config['MAIL_SERVER'] = os.getenv('MAIL_SERVER')
app.config['MAIL_PORT'] = os.getenv('MAIL_PORT')
app.config['MAIL_USERNAME'] = os.getenv('MAIL_USERNAME')
app.config['MAIL_PASSWORD'] = os.getenv('MAIL_PASSWORD')
app.config['MAIL_USE_TLS'] = os.getenv('MAIL_USE_TLS') == 'True'
app.config['MAIL_USE_SSL'] = os.getenv('MAIL_USE_SSL') == 'True'
mail = Mail(app)
@app.route('/postt')
def postt_view():
comments = Comment.query.filter_by(parent_id=None).all()
return render_template('postt.html', comments=comments)
@app.route('/add_comment', methods=['POST'])
def add_comment():
return model.add_comment_model()
@app.route('/delete_comment/<int:comment_id>', methods=['GET'])
def delete_comment(comment_id):
return model.delete_comment_model(comment_id=comment_id)
@app.route('/thesisjournal')
def thesis_journal():
return view.thesis_journal_view()
@app.route('/uploads/<filename>')
def uploaded_file(filename):
return send_from_directory(app.config['UPLOAD_FOLDER'], filename)
@app.route('/submit1', methods=['POST','GET'])
def submit1():
return model.submit1_model(request=request)
@app.route('/')
def homme():
return view.homme_view()
@app.route('/index')
def home():
return view.home_view()
@app.route('/courseinfo')
def cinfo():
return view.cinfo_view()
#Faculty Section Started
@app.route('/faculty_form', methods=['GET', 'POST'])
def faculty_form():
return model.faculty_form_model(request)
@app.route('/faculty')
def faculty():
return view.faculty_view()
@app.route('/faculty_description/<int:sno>', methods=['GET', 'POST'])
def delete(sno):
return model.delete_model(sno)
@app.route('/Add_resources', methods=['GET', 'POST'])
def Add_resources():
return model.Add_resources_model(request)
@app.route('/view')
def View():
return view.View_view()
@app.route('/community')
def community():
return view.community_view()
@app.route('/Alumni')
def Alumni():
return view.Alumni_view()
@app.route('/get_file/<int:sno>')
def get_file(sno):
return model.get_file_model(sno)
# @app.route('/upload', methods=['POST'])
# def upload_file():
# if 'file' not in request.files:
# return "No file part"
# file = request.files['file']
# if file.filename == '':
# return "No selected file"
# # Access the file name
# filename = file.filename
# # You can now use the 'filename' variable as needed
# return f'Uploaded file name: {filename}'
@app.route('/download/<filename>')
def download(filename):
return send_from_directory(app.config['UPLOAD_FOLDER'], filename, as_attachment=True)
@app.route('/cse1')
def cse1():
return view.cse1_view()
@app.route('/cse2')
def cse2():
return view.cse2_view()
@app.route('/cse3')
def cse3():
return view.cse3_view()
@app.route('/cse4')
def cse4():
return view.cse4_view()
comments = []
ratings = []
Serials=[]
course_codes=[]
@app.route('/comment')
def comment():
return view.comment_view(course_codes, Serials, comments, ratings)
@app.route('/submit', methods=['POST'])
def submit():
return model.submit_model(comments,ratings,course_codes,Serials)
# @app.route('/alumni')
# def alumni():
# return view.alumni_view(names, emails, c_names,c_types, dess)
# @app.route('/submitt', methods=['POST'])
# def submitt():
# return model.submitt_model(names,emails,c_names,c_types,dess)
names= []
emails = []
c_names=[]
dess=[]
c_types=[]
@app.route('/alumni')
def alumni():
alumnyy = [ ]
for i in range(len(names)):
alumnyy+=[{'name':names[i],'email':emails[i],'c_name':c_names[i],'c_type':c_types[i],'info':dess[i]}]
print(alumnyy)
return render_template('alumni.html', alumnyy=alumnyy)
@app.route('/submitt', methods=['POST'])
def submitt():
name = request.form.get('name')
email = request.form.get('email')
cname=request.form.get('cname')
c_type=request.form.get('c_type')
info=request.form.get('info')
if name and email and cname and c_type and info:
names.append(name)
emails.append(email)
c_names.append(cname)
c_types.append(c_type)
dess.append(info)
return redirect(url_for('alumni'))
#Event
events = []
@app.route('/event')
def event():
return view.event_view()
@app.route('/submittt', methods=['POST'])
def submittt():
return model.submittt_model(request)
#Internship
interns = []
@app.route('/intern')
def intern():
return view.intern_view()
@app.route('/submitttt', methods=['POST'])
def submitttt():
return model.submitttt_model(request=request)
#conference
conferences = []
@app.route('/conference')
def conference():
conferences_from_db = Conference.query.all()
return render_template('conference.html', conferences=conferences_from_db)
@app.route('/submittttt', methods=['POST'])
def submittttt():
return model.submittttt_model(request)
@app.route('/search', methods=['GET'])
def search():
return view.search_view(request)
if __name__ == "__main__":
with app.app_context():
db.create_all()
app.run(debug=True, port=8000)