mirror of
https://github.com/kennethreitz/responder.git
synced 2026-07-21 18:39:29 +00:00
31 lines
459 B
Python
31 lines
459 B
Python
"""The smallest useful Responder app.
|
|
|
|
Run it:
|
|
|
|
responder run examples/helloworld.py
|
|
|
|
Try it with:
|
|
|
|
curl http://127.0.0.1:5042/hello
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
import responder
|
|
|
|
api = responder.API(sessions=False)
|
|
|
|
|
|
@api.get("/")
|
|
def index(req, resp):
|
|
resp.text = "hello, world!"
|
|
|
|
|
|
@api.get("/{greeting}")
|
|
def greet_world(req, resp, *, greeting: str):
|
|
resp.text = f"{greeting}, world!"
|
|
|
|
|
|
if __name__ == "__main__":
|
|
api.run()
|