Skip to content

Commit

Permalink
Chore: Add another basic example
Browse files Browse the repository at this point in the history
  • Loading branch information
amotl committed Feb 2, 2025
1 parent 7b28390 commit a3a12cf
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions examples/user.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Example HTTP service definition, using Responder.
# https://pypi.org/project/responder/
import responder

api = responder.API()


@api.route("/")
async def index(req, resp):
resp.text = "Welcome"


@api.route("/user")
async def user_create(req, resp):
data = await req.media()
resp.text = f"Hello, {data['username']}"


@api.route("/user/{identifier}")
async def user_get(req, resp, *, identifier):
resp.text = f"Hello, user {identifier}"


if __name__ == "__main__":
api.run()

0 comments on commit a3a12cf

Please sign in to comment.