-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.py
More file actions
144 lines (111 loc) · 5.25 KB
/
app.py
File metadata and controls
144 lines (111 loc) · 5.25 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
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
from flask import Flask, render_template, request
import random
import os
import requests
import json
app = Flask(__name__, template_folder='template')
def find_category(city_name, category, api_key):
categories_endpoints = {
"restaurants": "restaurant",
"supermarches": "grocery_or_supermarket",
"sport": ["gym", "stadium", "yoga_studio", "natation_club", "handball_club", "football_club", "hockey_club", "basketbal_club", ],
"fastfood": "fast_food",
"divertissement": ["movie_theater", "museum", "bowling_alley", "escape_game", "theater", "concert", "amusement_park", "laser_game", "karting"]
}
query = f"{category} in {city_name}"
params = {
"query": query,
"key": api_key
}
response = requests.get(f"https://maps.googleapis.com/maps/api/place/textsearch/json?type={','.join(categories_endpoints[category])}", params=params)
if response.status_code == 200:
data = json.loads(response.text)
results = [place["name"] for place in data.get("results", [])]
cheap_results = [(place["name"], place.get("formatted_address", "")) for place in data.get("results", [])]
random_results = random.sample(cheap_results, min(5, len(cheap_results)))
return random_results
else:
return []
@app.route('/application.html')
def application():
return render_template('application.html')
@app.route('/applicationen.html')
def applicationen():
return render_template('applicationen.html')
@app.route('/applicationes.html')
def applicationes():
return render_template('applicationes.html')
@app.route('/faq.html')
def faq():
return render_template('faq.html')
@app.route('/faqen.html')
def faqen():
return render_template('faqen.html')
@app.route('/faqes.html')
def faqes():
return render_template('faqes.html')
@app.route('/point.html')
def point():
return render_template('point.html')
@app.route('/pointen.html')
def pointen():
return render_template('pointen.html')
@app.route('/pointes.html')
def pointes():
return render_template('pointes.html')
@app.route('/indexen.html', methods=['GET', 'POST'])
def chatbot_en():
show_text_input = False
recommendations = []
contact_creators_text = None
report_error_text = None
if request.method == 'POST':
user_input = request.form['user_input']
if user_input == "Contact us":
contact_creators_text = "Send us an email at : studexplorer@gmail.com"
elif user_input == "Report an error":
report_error_text = "Send us an email at : studexplorer@gmail.com"
elif user_input == "I want to find a cheap place to":
show_text_input = True
elif user_input in ["restaurants", "supermarches", "sport", "fastfood", "divertissement"]:
city = request.form['city']
recommendations = find_category(city, user_input, "#CLÉ API")
return render_template('indexen.html', show_text_input=show_text_input, recommendations=recommendations, contact_creators_text=contact_creators_text, report_error_text=report_error_text)
@app.route('/indexes.html', methods=['GET', 'POST'])
def chatbot_es():
show_text_input = False
recommendations = []
contact_creators_text = None
report_error_text = None
if request.method == 'POST':
user_input = request.form['user_input']
if user_input == "Contáctenos":
contact_creators_text = "Envíenos un correo electrónico a: studexplorer@gmail.com"
elif user_input == "Reportar un error":
report_error_text = "Envíenos un correo electrónico a: studexplorer@gmail.com"
elif user_input == "Quiero encontrar un lugar económico para":
show_text_input = True
elif user_input in ["restaurants", "supermarches", "sport", "fastfood", "divertissement"]:
city = request.form['city']
recommendations = find_category(city, user_input, "#CLÉ API")
return render_template('indexes.html', show_text_input=show_text_input, recommendations=recommendations, contact_creators_text=contact_creators_text, report_error_text=report_error_text)
@app.route('/index.html', methods=['GET', 'POST'])
def chatbot():
show_text_input = False
recommendations = []
contact_creators_text = None
report_error_text = None
if request.method == 'POST':
user_input = request.form['user_input']
if user_input == "Je veux contacter tes créateurs":
contact_creators_text = "Contactez-nous à l'adresse e-mail : studexplorer@gmail.com"
elif user_input == "Je veux reporter une erreur":
report_error_text = "Envoyez un e-mail à etudexplorers@gmail.com"
elif user_input == "Je cherche un lieu":
show_text_input = True
elif user_input in ["restaurants", "supermarches", "sport", "fastfood", "divertissement"]:
city = request.form['city']
recommendations = find_category(city, user_input, "#CLÉ API")
return render_template('index.html', show_text_input=show_text_input, recommendations=recommendations, contact_creators_text=contact_creators_text, report_error_text=report_error_text)
if __name__ == '__main__':
app.run(debug=True)