2022-12-01 00:42:07 +00:00
|
|
|
import falcon.asgi
|
|
|
|
from socketify import WSGI
|
|
|
|
|
|
|
|
|
|
|
|
class Home:
|
|
|
|
def on_get(self, req, resp):
|
|
|
|
resp.status = falcon.HTTP_200 # This is the default status
|
|
|
|
resp.content_type = falcon.MEDIA_TEXT # Default is JSON, so override
|
|
|
|
resp.text = "Hello, World!"
|
|
|
|
def on_post(self, req, resp):
|
2023-03-12 22:52:56 +00:00
|
|
|
raw_data = req.stream.read()
|
2022-12-01 00:42:07 +00:00
|
|
|
resp.status = falcon.HTTP_200 # This is the default status
|
|
|
|
resp.content_type = falcon.MEDIA_TEXT # Default is JSON, so override
|
2023-03-12 22:52:56 +00:00
|
|
|
resp.text = 'Ok'
|
2022-12-01 00:42:07 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app = falcon.App()
|
|
|
|
|
|
|
|
home = Home()
|
|
|
|
app.add_route("/", home)
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
2023-03-12 22:52:56 +00:00
|
|
|
WSGI(app).listen(8000, lambda config: print(f"Listening on port http://localhost:{config.port} now\n")).run(workers=1)
|