diff options
author | 2020-12-17 12:53:14 +0300 | |
---|---|---|
committer | 2020-12-17 12:55:59 +0300 | |
commit | 2552ca6aa43d148b12d19dd6c511fa14864cede4 (patch) | |
tree | b0e485760dec7c82f3165bfce0651f1f70534b07 /backend/routes/index.py | |
parent | Adds Webhook Sending Functionality (diff) | |
parent | Merge pull request #37 from python-discord/docs/api-spec (diff) |
Merge branch 'main' into discord-webhook
Signed-off-by: Hassan Abouelela <[email protected]>
# Conflicts:
# backend/routes/forms/submit.py
Diffstat (limited to 'backend/routes/index.py')
-rw-r--r-- | backend/routes/index.py | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/backend/routes/index.py b/backend/routes/index.py index b37f381..dd40d01 100644 --- a/backend/routes/index.py +++ b/backend/routes/index.py @@ -1,10 +1,24 @@ """ Index route for the forms API. """ +from pydantic import BaseModel +from pydantic.fields import Field +from spectree import Response from starlette.requests import Request from starlette.responses import JSONResponse from backend.route import Route +from backend.validation import api + + +class IndexResponse(BaseModel): + message: str = Field(description="A hello message") + client: str = Field( + description=( + "The connecting client, in production this will" + " be an IP of our internal load balancer" + ) + ) class IndexRoute(Route): @@ -17,7 +31,11 @@ class IndexRoute(Route): name = "index" path = "/" + @api.validate(resp=Response(HTTP_200=IndexResponse)) def get(self, request: Request) -> JSONResponse: + """ + Return a hello from Python Discord forms! + """ response_data = { "message": "Hello, world!", "client": request.client.host, |