socketify.py/examples/graceful_shutdown.py

23 wiersze
381 B
Python
Czysty Zwykły widok Historia

from socketify import App, AppOptions, AppListenOptions
app = App()
2022-11-16 19:28:46 +00:00
def shutdown(res, req):
res.end("Good bye!")
app.close()
2022-11-16 19:28:46 +00:00
app.get("/", lambda res, req: res.end("Hello!"))
app.get("/shutdown", shutdown)
2022-11-16 19:28:46 +00:00
app.listen(
3000,
lambda config: print(
"Listening on port http://localhost:%s now\n" % str(config.port)
),
)
app.run()
2022-11-16 19:28:46 +00:00
print("App Closed!")