Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
PizzaPalace
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
TheJoeCoder
PizzaPalace
Commits
b6147d25
Verified
Commit
b6147d25
authored
2 years ago
by
TheJoeCoder
Browse files
Options
Downloads
Patches
Plain Diff
Implement /status endpoint
parent
6a7c4307
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
server/app.py
+10
-2
10 additions, 2 deletions
server/app.py
with
10 additions
and
2 deletions
server/app.py
+
10
−
2
View file @
b6147d25
import
json
,
uuid
,
logging
,
requests
import
json
,
uuid
,
logging
,
requests
,
time
from
flask
import
Flask
,
request
,
jsonify
,
Response
from
pymongo
import
MongoClient
...
...
@@ -13,6 +13,8 @@ client = MongoClient(config.mongo_uri)
db
=
client
[
config
.
mongo_db
]
start_time
=
time
.
time
()
with
open
(
"
pizza_types.json
"
,
"
r
"
)
as
f
:
pizza_types
=
json
.
loads
(
f
.
read
())
...
...
@@ -42,6 +44,11 @@ def hello_world():
# Return OK message
return
"
{
\"
status
\"
:200,
\"
message
\"
:
\"
ok
\"
}
"
,
200
@app.route
(
"
/status
"
,
methods
=
[
"
GET
"
])
def
get_status
():
# Return status
return
"
{
\"
status
\"
:200,
\"
message
\"
:
\"
ok
\"
,
\"
uptime
\"
:
"
+
str
(
time
.
time
()
-
start_time
)
+
"
}
"
,
200
@app.route
(
"
/pizzas
"
,
methods
=
[
"
GET
"
])
def
get_pizzas
():
# Return pizza types
...
...
@@ -125,7 +132,7 @@ def add_cart_item():
})
return
"
{
\"
status
\"
:200,
\"
message
\"
:
\"
ok
\"
,
\"
items
\"
:
"
+
json
.
dumps
(
cart
[
"
items
"
])
+
"
}
"
,
200
@app.route
(
"
/cart/total
"
)
@app.route
(
"
/cart/total
"
,
methods
=
[
"
GET
"
]
)
def
get_cart_total
():
# Get cart id and key from request
cart_id
=
request
.
args
.
get
(
"
id
"
)
...
...
@@ -201,5 +208,6 @@ def confirm_order_cart():
# Return order ID
return
"
{
\"
status
\"
:200,
\"
message
\"
:
\"
OK
\"
,
\"
code
\"
:
\"
"
+
str
(
order_id
)
+
"
\"
}
"
,
200
# Main program code
if
(
__name__
==
"
__main__
"
):
app
.
run
(
debug
=
True
,
host
=
"
0.0.0.0
"
)
\ No newline at end of file
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