-
Notifications
You must be signed in to change notification settings - Fork 0
/
routes.py
92 lines (67 loc) · 2.05 KB
/
routes.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
from flask import Flask, render_template, request, session, flash, redirect, url_for, g
import requests
import rauth
import json
# import pdb
app = Flask(__name__)
app.config["DEBUG"] = True
app.config.from_object(__name__)
@app.route("/")
def main():
return render_template('main.html')
@app.route("/city", methods=["GET", "POST"])
def city_search():
get_location = request.form["location"]
params = {"term": "sushi", "radius_filter": "2000"}
params["location"] = [get_location]
#Obtain these from Yelp's manage access page
session = rauth.OAuth1Session(
consumer_key = consumer_key
,consumer_secret = consumer_secret
,access_token = token
,access_token_secret = token_secret)
get_data = session.get("http://api.yelp.com/v2/search",params=params)
#Transforms the JSON API response into a Python dictionary
data = get_data.json()
session.close()
return render_template('results.html', data=data)
# start the development server using the run() method
@app.route("/jiro_movie")
def jiro():
return render_template("jiro.html")
@app.route("/map")
def map():
# location_lat = data["region"]["center"]["latitude"]
# location_long = data["region"]["center"]["longitude"]
return render_template('map.html')
if __name__== "__main__":
app.run(debug=True)
# def get_search_parameters(lat,long):
# #See the Yelp API for more details
# params = {}
# params["term"] = "sushi"
# params["ll"] = "{},{}".format(str(lat),str(long))
# params["radius_filter"] = "2000"
# params["limit"] = "10"
# return params
# @app.route("/test/<search_query>")
# def search(search_query):
# return search_query
# @app.route("/integer/<int:value>")
# def int_type(value):
# print value + 1
# return "correct!"
# @app.route("/float/<float:value>")
# def float_type(value):
# print value + 1
# return "correct!"
# @app.route("/path/<path:value>")
# def path_type(value):
# print value
# return "correct!"
# @app.route("/name/<name>")
# def index(name):
# if name.lower() == "michael":
# return "Hello, {}".format(name), 200
# else:
# return "Not Found", 404