Skip to content

Commit

Permalink
fix: python not having healthcheck
Browse files Browse the repository at this point in the history
  • Loading branch information
kirinnee committed Nov 13, 2023
1 parent ff53a6f commit 95fc05b
Showing 1 changed file with 26 additions and 6 deletions.
32 changes: 26 additions & 6 deletions sdks/python/cyanprintsdk/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,13 @@
from cyanprintsdk.domain.template.service import TemplateService


async def health_check(request):
return web.json_response({
"Message": "OK",
"Status": "OK",
})


def start_plugin_with_fn(f: LambdaPluginFn):
start_plugin(LambdaPlugin(f))

Expand All @@ -59,7 +66,11 @@ async def plug(request):

return web.json_response(res.model_dump())

app.add_routes([web.post('/api/plug', plug)])
app.add_routes([
web.get("/", health_check),
web.post('/api/plug', plug),

])

web.run_app(app, port=5552)

Expand Down Expand Up @@ -89,7 +100,10 @@ async def process(request):

return web.json_response(res.model_dump())

app.add_routes([web.post('/api/process', process)])
app.add_routes([
web.get("/", health_check),
web.post('/api/process', process),
])

web.run_app(app, port=5551)

Expand Down Expand Up @@ -140,8 +154,11 @@ async def template_validate(request):

return web.json_response(res_model)

app.add_routes([web.post('/api/template/init', template_answer)])
app.add_routes([web.post('/api/template/validate', template_validate)])
app.add_routes([
web.get("/", health_check),
web.post('/api/template/init', template_answer),
web.post('/api/template/validate', template_validate),
])

web.run_app(app, port=5550)

Expand Down Expand Up @@ -187,7 +204,10 @@ async def ext_validate(request):

return web.json_response(res.model_dump())

app.add_routes([web.post('/api/extension/init', ext_answer)])
app.add_routes([web.post('/api/extension/validate', ext_validate)])
app.add_routes([
web.get("/", health_check),
web.post('/api/extension/init', ext_answer),
web.post('/api/extension/validate', ext_validate),
])

web.run_app(app, port=5550)

0 comments on commit 95fc05b

Please sign in to comment.