diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..bcf40641d6ad22c7414f94fe7cc96c97cc7ac61e Binary files /dev/null and b/.DS_Store differ diff --git a/movies.py b/movies.py index 9f6a2e23752f1843267d1f59f81abc51f831df1c..355e8cb908db7fb0227443974c62b2f919bc845e 100644 --- a/movies.py +++ b/movies.py @@ -1,5 +1,5 @@ -from services import root_dir, nice_json from flask import Flask +import flask_nicely from werkzeug.exceptions import NotFound import json import os @@ -10,16 +10,19 @@ with open("{}/database/movies.json".format(os.getcwd()), "r") as f: @app.route("/", methods=['GET']) +@flask_nicely.nice_json def hello(): - return nice_json({ + data = { "uri": "/", "subresource_uris": { "movies": "/movies", "movie": "/movies/<id>" } - }) + } + return data @app.route("/movies/<movieid>", methods=['GET']) +@flask_nicely.nice_json def movie_info(movieid): if movieid not in movies: raise NotFound @@ -27,12 +30,13 @@ def movie_info(movieid): result = movies[movieid] result["uri"] = "/movies/{}".format(movieid) - return nice_json(result) + return result @app.route("/movies", methods=['GET']) +@flask_nicely.nice_json def movie_record(): - return nice_json(movies) + return movies if __name__ == "__main__": diff --git a/showtimes.py b/showtimes.py index f4d236c65b6f21fe34daff95347a0a0d3687f4ed..74ac81eb79145c9a9789f52cd9ff0add78dbcc90 100644 --- a/showtimes.py +++ b/showtimes.py @@ -1,5 +1,5 @@ -from services import root_dir, nice_json from flask import Flask +import flask_nicely from werkzeug.exceptions import NotFound import json import os @@ -12,27 +12,32 @@ with open("{}/database/showtimes.json".format(os.getcwd()), "r") as f: @app.route("/", methods=['GET']) +@flask_nicely.nice_json def hello(): - return nice_json({ + + data = { "uri": "/", "subresource_uris": { "showtimes": "/showtimes", "showtime": "/showtimes/<date>" } - }) + } + return data @app.route("/showtimes", methods=['GET']) +@flask_nicely.nice_json def showtimes_list(): - nice_json(showtimes) + return showtimes @app.route("/showtimes/<date>", methods=['GET']) +@flask_nicely.nice_json def showtimes_record(date): if date not in showtimes: raise NotFound print(showtimes[date]) - return nice_json(showtimes[date]) + return showtimes[date] if __name__ == "__main__": app.run(port=5002, debug=True)