Created
July 9, 2021 05:51
-
-
Save hamaguchi-amago/f49a825affcff52a541aeb99f8eecc92 to your computer and use it in GitHub Desktop.
FastAPIで空欄のINPUTをPOSTすると発生するエラーの解消方法
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from typing import Optional | |
from fastapi import ( | |
APIRouter, | |
Form, | |
) | |
router = APIRouter() | |
@router.post("/ng") | |
async def ng_function( | |
user_name: str = Form(...) | |
): | |
print(user_name) | |
@router.post("/ok") | |
async def ok_function( | |
user_name: Optional[str] = Form(None) | |
): | |
print(user_name) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
ブログの記事で作成しました。
興味のある方はご覧ください。
【FastAPI】空欄のINPUTをPOSTするとエラーになる
https://neko-py.com/fastapi-form-blank-error