-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
76 additions
and
34 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,9 @@ | ||
from fastapi import APIRouter | ||
from fastapi import APIRouter, Request | ||
|
||
router = APIRouter(include_in_schema=False) | ||
|
||
|
||
@router.get("/") | ||
async def home(): | ||
return {"message": "Hello World from FastAPI"} | ||
async def home(request: Request): | ||
client_host = request.client.host | ||
return {"message": "Hello World from FastAPI", "client_host": client_host} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
from pydantic_settings import BaseSettings, SettingsConfigDict | ||
|
||
# from typing import Annotated | ||
# from pydantic import AfterValidator, HttpUrl | ||
# HttpUrlString = Annotated[HttpUrl, AfterValidator(str)] | ||
|
||
|
||
class Settings(BaseSettings): | ||
frontendschema: str = "http" | ||
frontendhost: str = "localhost" | ||
frontendport: int = 7000 | ||
frontendreload: bool = False | ||
|
||
backendschema: str = "http" | ||
backendhost: str = "localhost" | ||
backendport: int = 8000 | ||
backendreload: bool = False | ||
|
||
tz: str = "UTC" | ||
|
||
model_config = SettingsConfigDict(env_file=".env", env_file_encoding="utf-8") | ||
|
||
|
||
settings = Settings() |
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,24 @@ | ||
from pydantic import HttpUrl | ||
from pydantic_settings import BaseSettings, SettingsConfigDict | ||
|
||
# from typing import Annotated | ||
# from pydantic import AfterValidator, HttpUrl | ||
# HttpUrlString = Annotated[HttpUrl, AfterValidator(str)] | ||
|
||
|
||
class Settings(BaseSettings): | ||
frontendhost: HttpUrl = "http://localhost" | ||
frontendschema: str = "http" | ||
frontendhost: str = "localhost" | ||
frontendport: int = 7000 | ||
frontenddebug: bool = False | ||
frontendreload: bool = False | ||
|
||
backendhost: HttpUrl = "http://localhost" | ||
backendschema: str = "http" | ||
backendhost: str = "localhost" | ||
backendport: int = 8000 | ||
backendreload: bool = False | ||
|
||
tz: str = "UTC" | ||
|
||
model_config = SettingsConfigDict(env_file=".env", env_file_encoding="utf-8") | ||
|
||
|
||
settings = Settings() | ||
# print(f"{settings=} from frontend") |
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