Forked from
COM3014 / microservices
2 commits behind the upstream repository.
Code owners
Assign users and groups as approvers for specific file changes. Learn more.
showtimes.py 825 B
from services import root_dir, nice_json
from flask import Flask
from werkzeug.exceptions import NotFound
import json
import os
app = Flask(__name__)
with open("{}/database/showtimes.json".format(os.getcwd()), "r") as f:
showtimes = json.load(f)
@app.route("/", methods=['GET'])
def hello():
return nice_json({
"uri": "/",
"subresource_uris": {
"showtimes": "/showtimes",
"showtime": "/showtimes/<date>"
}
})
@app.route("/showtimes", methods=['GET'])
def showtimes_list():
nice_json(showtimes)
@app.route("/showtimes/<date>", methods=['GET'])
def showtimes_record(date):
if date not in showtimes:
raise NotFound
print(showtimes[date])
return nice_json(showtimes[date])
if __name__ == "__main__":
app.run(port=5002, debug=True)