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
Foster, Sam C (UG - Computer Science)
microservices
Commits
7b8f5db7
Commit
7b8f5db7
authored
4 years ago
by
Foster, Sam C (UG - Computer Science)
Browse files
Options
Downloads
Patches
Plain Diff
added json dumps instead of flask nicely
parent
053160a0
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
movies.py
+5
-5
5 additions, 5 deletions
movies.py
showtimes.py
+9
-9
9 additions, 9 deletions
showtimes.py
with
14 additions
and
14 deletions
movies.py
+
5
−
5
View file @
7b8f5db7
from
services
import
root_dir
,
nice_json
from
flask
import
Flask
from
flask
import
Flask
from
werkzeug.exceptions
import
NotFound
from
werkzeug.exceptions
import
NotFound
import
json
import
json
...
@@ -11,13 +10,14 @@ with open("{}/database/movies.json".format(os.getcwd()), "r") as f:
...
@@ -11,13 +10,14 @@ with open("{}/database/movies.json".format(os.getcwd()), "r") as f:
@app.route
(
"
/
"
,
methods
=
[
'
GET
'
])
@app.route
(
"
/
"
,
methods
=
[
'
GET
'
])
def
hello
():
def
hello
():
return
nice_json
(
{
data
=
{
"
uri
"
:
"
/
"
,
"
uri
"
:
"
/
"
,
"
subresource_uris
"
:
{
"
subresource_uris
"
:
{
"
movies
"
:
"
/movies
"
,
"
movies
"
:
"
/movies
"
,
"
movie
"
:
"
/movies/<id>
"
"
movie
"
:
"
/movies/<id>
"
}
}
})
}
return
json
.
dumps
(
data
)
@app.route
(
"
/movies/<movieid>
"
,
methods
=
[
'
GET
'
])
@app.route
(
"
/movies/<movieid>
"
,
methods
=
[
'
GET
'
])
def
movie_info
(
movieid
):
def
movie_info
(
movieid
):
...
@@ -27,12 +27,12 @@ def movie_info(movieid):
...
@@ -27,12 +27,12 @@ def movie_info(movieid):
result
=
movies
[
movieid
]
result
=
movies
[
movieid
]
result
[
"
uri
"
]
=
"
/movies/{}
"
.
format
(
movieid
)
result
[
"
uri
"
]
=
"
/movies/{}
"
.
format
(
movieid
)
return
nice_json
(
result
)
return
json
.
dumps
(
result
)
@app.route
(
"
/movies
"
,
methods
=
[
'
GET
'
])
@app.route
(
"
/movies
"
,
methods
=
[
'
GET
'
])
def
movie_record
():
def
movie_record
():
return
nice_json
(
movies
)
return
json
.
dumps
(
movies
)
if
__name__
==
"
__main__
"
:
if
__name__
==
"
__main__
"
:
...
...
This diff is collapsed.
Click to expand it.
showtimes.py
+
9
−
9
View file @
7b8f5db7
from
services
import
root_dir
,
nice_json
from
flask
import
Flask
from
flask
import
Flask
from
werkzeug.exceptions
import
NotFound
from
werkzeug.exceptions
import
NotFound
import
json
import
json
...
@@ -16,18 +15,19 @@ with open(showtimes_db, "r") as f:
...
@@ -16,18 +15,19 @@ with open(showtimes_db, "r") as f:
@app.route
(
"
/
"
,
methods
=
[
'
GET
'
])
@app.route
(
"
/
"
,
methods
=
[
'
GET
'
])
def
hello
():
def
hello
():
return
nice_json
({
data
=
{
"
uri
"
:
"
/
"
,
"
uri
"
:
"
/
"
,
"
subresource_uris
"
:
{
"
subresource_uris
"
:
{
"
showtimes
"
:
"
/showtimes
"
,
"
showtimes
"
:
"
/showtimes
"
,
"
showtime
"
:
"
/showtimes/<date>
"
"
showtime
"
:
"
/showtimes/<date>
"
}
}
}
}
)
return
json
.
dumps
(
data
)
@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
'
])
...
@@ -39,7 +39,7 @@ def showtimes_record(date):
...
@@ -39,7 +39,7 @@ def showtimes_record(date):
for
movie_id
in
showtimes
[
date
]:
for
movie_id
in
showtimes
[
date
]:
resp
=
requests
.
get
(
movies_service
.
format
(
movie_id
))
resp
=
requests
.
get
(
movies_service
.
format
(
movie_id
))
result
.
append
(
resp
.
json
()[
"
title
"
])
result
.
append
(
resp
.
json
()[
"
title
"
])
return
nice_json
(
result
)
return
json
.
dumps
(
result
)
if
__name__
==
"
__main__
"
:
if
__name__
==
"
__main__
"
:
app
.
run
(
port
=
5002
,
debug
=
True
)
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