-
Notifications
You must be signed in to change notification settings - Fork 2
/
app.py
49 lines (41 loc) · 1.36 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
import os, redis, warnings
from flask import Flask, request, redirect
from usher.movies_endpoint import MoviesEndpoint
# Setup 2 caches, one for
# - local time results
# - military time results
local_time_cache = redis.from_url(os.environ.get('REDIS_URL'), 0)
military_time_cache = redis.from_url(os.environ.get('REDIS_URL'), 1)
app = Flask(__name__)
@app.route('/')
def home():
return """
<p>main-endpoint:
<a href='/v2/movies'>
google.com-movies-scraper.herokuapp.com/v2/movies?{near[, date, militaryTime]}
</a>
</p>
<p>docs (apiary.io):
<a href='/docs'>
google-movies-scraper.herokuapp.com/docs
</a>
</p>
<p>github:
<a href='https://github.com/stevenpollack/gms'>
https://github.com/stevenpollack/gms
</a>
</p>
"""
@app.route('/docs')
def route_to_apiary():
apiary_io = 'http://docs.googlemoviesscraper.apiary.io/'
return (redirect(apiary_io, code=302))
@app.route('/v2/movies', methods=['GET'])
def serve_movies():
near = request.args.get('near')
days_from_now = request.args.get('date')
use_military_time = request.args.get('militaryTime')
endpoint = MoviesEndpoint(near, days_from_now, use_military_time, local_time_cache, military_time_cache)
return endpoint.process_request()
if (__name__ == '__main__'):
app.run(debug=True, host='0.0.0.0', port=5001)