init.py in submodules, aliases for different redirections
This commit is contained in:
parent
03e4c63d38
commit
6b9d616808
7 changed files with 75 additions and 42 deletions
27
app/forms/__init__.py
Normal file
27
app/forms/__init__.py
Normal file
|
@ -0,0 +1,27 @@
|
|||
"""Module containing WTForms classes
|
||||
and helper functions for Starlette-WTF"""
|
||||
|
||||
from typing import Type, TypeVar
|
||||
|
||||
from fastapi import Request
|
||||
from starlette_wtf import StarletteForm
|
||||
|
||||
T = TypeVar('T', bound=StarletteForm)
|
||||
|
||||
|
||||
async def get_form(
|
||||
form: Type[T],
|
||||
req: Request) -> T:
|
||||
"""Almost the same as `form.from_formdata`,
|
||||
and must be used *instead* of instantiatng
|
||||
form object directly as in Flask
|
||||
|
||||
Args:
|
||||
form (Type[StarletteForm]): StarletteForm class
|
||||
req (Request): Request object
|
||||
|
||||
Returns:
|
||||
StarletteForm instance
|
||||
"""
|
||||
|
||||
return await form.from_formdata(request=req)
|
Loading…
Add table
Reference in a new issue