Skip to content
Snippets Groups Projects
Commit 061c4dc5 authored by Khalid, Rizwan (UG - Computer Science)'s avatar Khalid, Rizwan (UG - Computer Science)
Browse files

Updated showtimes.py to return movie names, not ids

parent 5f8b89d9
No related branches found
No related tags found
No related merge requests found
from flask import Flask from flask import Flask
from werkzeug.exceptions import NotFound from werkzeug.exceptions import NotFound
import json import json
import requests
import os import os
app = Flask(__name__) app = Flask(__name__)
movies_service = "http://127.0.0.1:5001/movies/{}"
with open("{}/database/showtimes.json".format(os.getcwd()), "r") as f: with open("{}/database/showtimes.json".format(os.getcwd()), "r") as f:
showtimes = json.load(f) showtimes = json.load(f)
...@@ -23,15 +24,18 @@ def hello(): ...@@ -23,15 +24,18 @@ def hello():
@app.route("/showtimes", methods=['GET']) @app.route("/showtimes", methods=['GET'])
def showtimes_list(): def showtimes_list():
nice_json(showtimes) return json.dumps(showtimes)
@app.route("/showtimes/<date>", methods=['GET']) @app.route("/showtimes/<date>", methods=['GET'])
def showtimes_record(date): def showtimes_record(date):
if date not in showtimes: if date not in showtimes:
raise NotFound raise NotFound
print(showtimes[date]) result = []
return json.dumps(showtimes[date]) for movie_id in showtimes[date]:
resp = requests.get(movies_service.format(movie_id))
result.append(resp.json()["title"])
return json.dumps(result)
if __name__ == "__main__": if __name__ == "__main__":
app.run(port=5002, debug=True) app.run(port=5002, debug=True)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment