Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
M
microservices
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Segana, Mike (UG - Comp Sci & Elec Eng)
microservices
Commits
a0033b18
Commit
a0033b18
authored
3 months ago
by
Ubuntu
Browse files
Options
Downloads
Patches
Plain Diff
Modified showtimes.py to fetch movie titles
parent
fd5e32b3
Branches
master
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
showtimes.py
+18
-2
18 additions, 2 deletions
showtimes.py
with
18 additions
and
2 deletions
showtimes.py
+
18
−
2
View file @
a0033b18
#
import
requests
#
from
services
import
root_dir
,
nice_json
from
flask
import
Flask
from
werkzeug.exceptions
import
NotFound
...
...
@@ -9,8 +12,16 @@ app = Flask(__name__)
with
open
(
"
{}/database/showtimes.json
"
.
format
(
os
.
getcwd
()),
"
r
"
)
as
f
:
showtimes
=
json
.
load
(
f
)
##
MOVIES_SERVICE_URL
=
"
http://127.0.0.1:5001/movies
"
def
get_movie_title
(
movie_id
):
response
=
requests
.
get
(
f
"
{
MOVIES_SERVICE_URL
}
/
{
movie_id
}
"
)
if
response
.
status_code
==
200
:
return
response
.
json
().
get
(
"
title
"
)
return
none
##
@app.route
(
"
/
"
,
methods
=
[
'
GET
'
])
def
hello
():
return
nice_json
({
...
...
@@ -31,8 +42,13 @@ def showtimes_list():
def
showtimes_record
(
date
):
if
date
not
in
showtimes
:
raise
NotFound
print
(
showtimes
[
date
])
return
nice_json
(
showtimes
[
date
])
#convert movie IDs to movie titles
movie_ids
=
showtimes
[
date
]
movie_titles
=
[
get_movie_title
(
movie_id
)
for
movie_id
in
movie_ids
]
# print(showtimes[date])
# return nice_json(showtimes[date])
return
nice_json
(
movie_titles
)
if
__name__
==
"
__main__
"
:
app
.
run
(
port
=
5002
,
debug
=
True
)
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment