forked from su11ji04/MEP
-
Notifications
You must be signed in to change notification settings - Fork 0
/
application.py
253 lines (199 loc) ยท 8.14 KB
/
application.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
from flask import Flask, render_template, request, redirect, url_for
from database import DBhandler
import sys
application = Flask(__name__)
DB = DBhandler()
@application.route("/") #๋ฉ์ธ ํ๋ฉด
def hello():
#return render_template("index.html")
return redirect(url_for('list_restaurants')) #12์ฃผ์ฐจ ๊ฐ์์๋ฃ-8@application.route("/") #๋ฉ์ธ ํ๋ฉด
@application.route("/1") #์์
def hellotemp():
return render_template("index.html")
@application.route("/write_review") #๋ฆฌ๋ทฐ ์์ฑ ํ๋ฉด
def write_review():
return render_template("Review_Write.html")
@application.route("/view_review") #๋ฆฌ๋ทฐ ์กฐํ ํ๋ฉด
def view_review():
return render_template("Review_Check.html")
@application.route("/write_mep") #๋ง์ง ๋ฑ๋ก ํ๋ฉด
def write_mep():
return render_template("mep_registration.html")
@application.route("/add_menu") #๋ฉ๋ด ๋ฑ๋ก ํ๋ฉด
def add_menu():
return render_template("Add_Menu.html")
@application.route("/show_menu") #๋ฉ๋ด ๋ณด๊ธฐ ํ๋ฉด
def show_menu():
return render_template("Show_Menu.html")
@application.route("/result") #๋ง์ง ๋ฑ๋ก ์
๋ ฅ๊ฐ ์ถ๋ ฅ result ํ๋ฉด
def result():
return render_template("result.html")
@application.route("/JoinUs") #ํ์๊ฐ์
ํ๋ฉด
def JoinUs():
return render_template("JoinUs.html")
@application.route("/login") #๋ก๊ทธ์ธ ํ๋ฉด
def login():
return render_template("login_index.html")
@application.route("/food_course") #์ถ์ฒ๋ฃจํธ๊ฒ์ํ ํ๋ฉด
def food_course():
return render_template("foodcourse.html")
@application.route("/korea") #ํ์ ํ๋ฉด
def view_korea():
return render_template("korea_index.html")
@application.route("/china") #์ค์ ํ๋ฉด
def view_china():
return render_template("china_index.html")
@application.route("/japan") #์ผ์ ํ๋ฉด
def view_japan():
return render_template("japan_index.html")
@application.route("/west") #์์ ํ๋ฉด
def view_west():
return render_template("western_index.html")
@application.route("/fast") #ํจ์คํธํธ๋ ํ๋ฉด
def view_fast():
return render_template("fastfood_index.html")
@application.route("/dessert") #๋์ ํธ ํ๋ฉด
def view_desert():
return render_template("dessert_index.html")
@application.route("/mep_page") #๋ง์ง ์ธ๋ถ ํ๋ฉด
def view_mep():
return render_template("mep_page.html")
#@application.route("/submit_review/<name>/")
#def review_submit():
# data = DB.get_restaurant_byname(str(name))
# print('####data:', data)
# return True
#result.html ์์ ๋ฉ๋ด๋ฑ๋กํ๋ฉด์ผ๋ก ๋ณด๋ด๊ธฐ
@application.route("/submit_result_html", methods=['POST'])
def result_submit():
image_file=request.files["file"]
image_file.save("./static/image_upload/{}".format(image_file.filename))
data=request.form
print(data)
return render_template("Add_Menu.html", data=data)
#๋ง์ง ๋ฑ๋ก ํ๋ฉด ์
๋ ฅ๊ฐ ๋ณด๋ด๊ธฐ
@application.route("/submit_registration", methods=['POST'])
def mep_registration_submit():
image_file=request.files["file"]
image_file.save("./static/image_upload/{}".format(image_file.filename))
data=request.form
if DB.insert_restaurant(data['review_name'], data, image_file.filename):
return render_template("result.html", data=data, image_path="./static/image_upload/"+image_file.filename)
else:
return "Restaurant name already exist!"
#ํ์๊ฐ์
ํ๋ฉด ์
๋ ฅ๊ฐ ๋ณด๋ด๊ธฐ
@application.route("/submit_JoinUs", methods=['POST'])
def JoinUs_submit():
data=request.form
print(data)
#return render_template("JoinUs.html", data=data)
#๋ก๊ทธ์ธ ํ๋ฉด ์
๋ ฅ๊ฐ ๋ณด๋ด๊ธฐ
@application.route("/submit_login", methods=['POST'])
def login_submit():
data=request.form
print(data)
#return render_template("login_index.html", data=data)
#์ถ์ฒ๋ฃจํธ ๊ฒ์ํ ์
๋ ฅ๊ฐ ๋ณด๋ด๊ธฐ
@application.route("/submit_foodcourse", methods=['POST'])
def reg_foodcourse_submit():
image_file=request.files["file"]
image_file.save("./static/image_upload/"+image_file.filename)
data = request.form
print(data)
#return render_template("foodcourse.html", data=data)
# #๋ฉ๋ด ๋ฑ๋ก ํ๋ฉด ์
๋ ฅ๊ฐ ๋ณด๋ด๊ธฐ
# @application.route("/submit_menu", methods=['POST'])
# def add_menu_submit():
# image_file=request.files["file"]
# image_file.save("./static/image_upload/{}".format(image_file.filename))
# data=request.form
# if DB.insert_menu(data['menu_name'], data, image_file.filename):
# return render_template("Show_Menu.html", data=data, menu_image_path="./static/image_upload/"+image_file.filename)
# else:
# return "Menu name already exist!"
#12์ฃผ์ฐจ ๊ฐ์์๋ฃ 10ํ์ด์ง
@application.route("/list")
def list_restaurants():
page = request.args.get("page", 0, type=int)
limit = 9
start_idx = limit*page
end_idx = limit*(page+1)
data = DB.get_restaurants() #read the table
tot_count = len(data)
data = dict(list(data.items())[start_idx:end_idx])
# url_for('list_restaurants', page=i)
return render_template(
"list.html",
datas=data.items(),
total=tot_count,
limit=limit,
page=page,
page_count=int((tot_count/10)+1)
)
#12์ฃผ์ฐจ ๊ฐ์์๋ฃ 18ํ์ด์ง
@application.route('/dynamicurl/<variable_name>/')
def DynamicUrl(variable_name):
return str(variable_name)
#12์ฃผ์ฐจ ๊ฐ์์๋ฃ 20ํ์ด์ง
@application.route("/mep_page/<name>/")
def view_restaurant_detail(name):
data = DB.get_restaurant_byname(str(name))
#avg_rate = DB.get_avgrate_byname(str(name))
print("####data:",data)
return render_template("mep_page.html", data=data) #, avg_rate=avg_rate)
#์์ธํ๋ฉด->๋ฆฌ๋ทฐ์กฐํํ๋ฉด์ผ๋ก ์ฎ๊ธฐ๋
@application.route("/review_check/<name>/")
def review_check(name):
data = DB.get_restaurant_byname(str(name))
#avg_rate = DB.get_avgrate_byname(str(name))
print("####data:",data)
return render_template("Review_Check.html", data=data)
#๋ฆฌ๋ทฐ์กฐํํ๋ฉด -> ๋ฆฌ๋ทฐ์์ฑํ๋ฉด
@application.route("/review_write/<name>/")
def review_write(name):
data = DB.get_restaurant_byname(str(name))
#avg_rate = DB.get_avgrate_byname(str(name))
print("####data:",data)
return render_template("Review_Write.html", data=data)
#12์ฃผ์ฐจ ๊ฐ์์๋ฃ 26ํ์ด์ง
#๋ง์ง ์ธ๋ถ ํ๋ฉด์์ ๋ํ๋ฉ๋ด ํ๋ฉด์ผ๋ก ๋์ด๊ฐ๊ธฐ
@application.route("/show_menu/<name>/")
def view_menu(name):
# data = DB.get_restaurant_byname(str(name))
# print('####data:', data)
# tot_count = len(data)
# return render_template("Show_Menu.html", datas=data.items(), total=tot_count)
data = DB.get_food_byname(str(name))
tot_count = len(data)
return render_template("Show_Menu.html", datas=data, total=tot_count)
#๋ฉ๋ด ๋ฑ๋ก ํ๋ฉด ๋์ ๋ผ์ฐํ
@application.route("/add_menu/<name>/")
def mep_add_menu(name):
data = DB.get_restaurant_byname(str(name))
print("####data:",data)
return render_template("Add_Menu.html", data=data)
#๋ฉ๋ด ๋ฑ๋ก ํ๋ฉด ์
๋ ฅ๊ฐ ๋ณด๋ด๊ธฐ
@application.route("/submit_show_menu", methods=['POST'])
def menu_submit():
image_file=request.files["file"]
image_file.save("./static/image_upload/"+image_file.filename)
data = request.form
print(data)
if DB.insert_menu(data['menu_name'], data, image_file.filename):
#return render_template("Show_Menu.html", data=data, menu_image_path="./static/image_upload/"+image_file.filename)
return render_template("Show_Menu.html", data=data, menu_image_path="./static/image_upload/"+image_file.filename)
else:
return "Menu name already exist!"
# return render_template("Show_Menu.html", data=data)
#๋ฆฌ๋ทฐ ๋ฑ๋ก ํ๋ฉด ์
๋ ฅ๊ฐ ๋ณด๋ด๊ธฐ
@application.route("/submit_review", methods=['POST'])
def submit_review():
image_file=request.files["file"]
image_file.save("./static/image_upload/"+image_file.filename)
data = request.form
if DB.insert_review(data['review_name'], data, image_file.filename):
return render_template("Review_Check.html", data=data, review_img_path="./static/image_upload/"+image_file.filename)
else:
return "Restaurant name already exist!"
if __name__ == "__main__":
application.run(host='0.0.0.0', debug= True)