Skip to content
Snippets Groups Projects
Commit dd5c28d5 authored by Foster, Sam C (UG - Computer Science)'s avatar Foster, Sam C (UG - Computer Science)
Browse files

remove services import

parent 1bc108e6
No related branches found
No related tags found
No related merge requests found
.DS_Store 0 → 100644
File added
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__":
......
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)
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