better errors

This commit is contained in:
Waylon S. Walker 2024-10-17 08:20:37 -05:00
parent c8afba360b
commit 19db26b0cb
5 changed files with 84 additions and 82 deletions

View file

@ -1,6 +1,4 @@
from fastapi import APIRouter
from fastapi import Depends
from fastapi import Request
from fastapi import APIRouter, Depends, Request
from fastapi_dynamic_response.base.schema import Message
from fastapi_dynamic_response.dependencies import get_content_type
@ -17,6 +15,16 @@ async def get_example(
return {"message": "Hello, this is an example", "data": [1, 2, 3, 4]}
@router.get("/error")
async def get_error(
request: Request,
content_type: str = Depends(get_content_type),
):
request.state.template_name = "example.html"
0 / 0
return {"message": "Hello, this is an example", "data": [1, 2, 3, 4]}
@router.get("/another-example")
async def another_example(
request: Request,
@ -30,6 +38,16 @@ async def another_example(
}
@router.get("/message")
async def message(
request: Request,
message_id: int,
content_type: str = Depends(get_content_type),
):
request.state.template_name = "post_message.html"
return {"message": message.message}
@router.post("/message")
async def message(
request: Request,