-
Notifications
You must be signed in to change notification settings - Fork 1
/
app.py
76 lines (56 loc) · 2.17 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
from flask import Flask, redirect, render_template, request, url_for
import currency
import restaurants
import videos
from currency_map import country_to_currency, get_full_country_name
app = Flask(__name__)
@app.route("/")
def homepage():
return render_template("index.html")
@app.route("/travelguide", methods=["GET", "POST"])
def get_travel_info():
# From the form input that the submits
home_countrycode = request.args.get("country-from")
destination_countrycode = request.args.get("country-destination")
city = request.args.get("city-destination").capitalize()
destination_country_full_name = get_full_country_name(destination_countrycode)
home_country_full_name = get_full_country_name(home_countrycode)
# Conveting from 2 letter cc to 3 letter currency code
home_currency = country_to_currency(get_full_country_name(home_countrycode))
destination_currency = country_to_currency(
get_full_country_name(destination_countrycode)
)
# Calling the APIs
money = currency.get_exchange_rate(home_currency, destination_currency)
food = restaurants.get_restaurants(city, destination_countrycode, 20)
vids = videos.get_videos(city, destination_country_full_name)
return render_template(
"travelguide.html",
home_countrycode=home_countrycode,
destination_country_full_name=destination_country_full_name,
home_country_full_name=home_country_full_name,
city=city,
vids=vids,
food=food,
money=money,
# fullname_country_destination=fullname_country_destination
)
@app.route("/about/")
def about():
return render_template("about.html")
@app.route("/save", methods=["POST"])
def save(methods=["POST"]):
saved_item = request.form["name"]
saved_item = request.form["url"]
saved_item = request.form["country"]
saved_item = request.form["city"]
saved_item = request.form["type"]
return redirect(url_for("bookmark"))
@app.route("/bookmark")
def bookmark():
return render_template("bookmarks.html")
if __name__ == "__main__":
app.run(debug=True)
@app.errorhandler(404)
def page_not_found(e):
return render_template("error.html"), 404