-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathapp.py
More file actions
47 lines (39 loc) · 1.43 KB
/
app.py
File metadata and controls
47 lines (39 loc) · 1.43 KB
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
import os
from flask import Flask, render_template, url_for, redirect, request
from final import Restaurant
app = Flask(__name__)
env_config = os.getenv('APP_SETTINGS', 'config.ProductionConfig')
app.config.from_object(env_config)
def get_restaurants(max_Price, people, min_Price, cuisine, locality):
ansh = Restaurant(max_Price, people, min_Price, cuisine, locality)
Restaurant.rest(ansh)
ans = ansh.rest_list
ans = ans.to_dict()
res = [value for value in ans.values()]
return res
@app.route("/")
@app.route("/home", methods=['GET', 'POST'])
def home():
return render_template('base.html')
@app.route("/search", methods=['GET', 'POST'])
def search():
if request.args:
people = int(request.args.get('guests'))
min_Price = int(request.args.get('minBudget'))
max_Price = int(request.args.get('maxBudget'))
cuisine = request.args.get('cuisine')
locality = request.args.get('locality')
# to input values into html form
input = {
'guests': people,
'minBudget': min_Price,
'maxBudget': max_Price,
'cuisine': cuisine,
'locality': locality
}
restaurants = get_restaurants(max_Price, people, min_Price, [cuisine], [locality])
return render_template('search.html', restaurants=restaurants, input=input )
else:
return redirect(url_for('home'))
if __name__ == '__main__':
app.run()