Skip to content

๐ŸŽฒ ๐Ÿ—„

๐Ÿšฅ ๐Ÿ‘† ๐Ÿ’ช, ๐Ÿ‘† ๐Ÿ’ช โš™๏ธ โš’ & ๐ŸŒ ๐Ÿ”ข ๐Ÿ”— ๐Ÿ—„ โœ” โš“๏ธ ๐Ÿ”› ๐ŸŒ, & โŽ โšซ๏ธ ๐Ÿ•.

๐Ÿ”ƒ ๐Ÿ’‚โ€โ™‚, ๐Ÿ”—, & ๐Ÿฉบ

๐Ÿ•ตโ€โ™‚ ๐Ÿ‘† ๐Ÿงพ ๐Ÿ‘ฉโ€๐Ÿ’ป ๐Ÿ”ข ๐Ÿญ ๐Ÿšซ๐Ÿ”œ ๐Ÿšซ ๐ŸŒŒ ๐Ÿ›ก ๐Ÿ‘† ๐Ÿ› ๏ธ.

๐Ÿ‘ˆ ๐Ÿšซ ๐Ÿšฎ ๐Ÿ™† โž• ๐Ÿ’‚โ€โ™‚ ๐Ÿ‘† ๐Ÿ› ๏ธ, โžก ๐Ÿ› ๏ธ ๐Ÿ”œ ๐Ÿ’ช ๐ŸŒโ” ๐Ÿ‘ซ.

๐Ÿšฅ ๐Ÿ“ค ๐Ÿ’‚โ€โ™‚ โš  ๐Ÿ‘† ๐Ÿ“Ÿ, โšซ๏ธ ๐Ÿ”œ ๐Ÿ”€.

๐Ÿ•ตโ€โ™‚ ๐Ÿงพ โš’ โšซ๏ธ ๐ŸŒ… โš  ๐Ÿค” โ” ๐Ÿ”— โฎ๏ธ ๐Ÿ‘† ๐Ÿ› ๏ธ, & ๐Ÿ’ช โš’ โšซ๏ธ ๐ŸŒ… โš  ๐Ÿ‘† โ„น โšซ๏ธ ๐Ÿญ. โšซ๏ธ ๐Ÿ’ช ๐Ÿค” ๐ŸŽฏ ๐Ÿ“จ ๐Ÿ’‚โ€โ™‚ ๐Ÿ”˜ ๐ŸŒŒ.

๐Ÿšฅ ๐Ÿ‘† ๐Ÿ’š ๐Ÿ” ๐Ÿ‘† ๐Ÿ› ๏ธ, ๐Ÿ“ค ๐Ÿ“š ๐Ÿ‘ ๐Ÿ‘œ ๐Ÿ‘† ๐Ÿ’ช, ๐Ÿ–ผ:

  • โš’ ๐Ÿ’ญ ๐Ÿ‘† โœ”๏ธ ๐Ÿ‘ ๐Ÿ”ฌ Pydantic ๐Ÿท ๐Ÿ‘† ๐Ÿ“จ ๐Ÿ’ช & ๐Ÿ“จ.
  • ๐Ÿ”— ๐Ÿ™† โœ” โœ” & ๐Ÿ”‘ โš™๏ธ ๐Ÿ”—.
  • ๐Ÿ™… ๐Ÿช ๐Ÿ”ข ๐Ÿ”, ๐Ÿ•ด ๐Ÿ”#๏ธโƒฃ.
  • ๐Ÿ› ๏ธ & โš™๏ธ ๐Ÿ‘-๐Ÿ’ญ ๐Ÿ” ๐Ÿงฐ, ๐Ÿ’– ๐Ÿ‡ธ๐Ÿ‡ฒ & ๐Ÿฅ™ ๐Ÿค, โ™’๏ธ.
  • ๐Ÿšฎ ๐ŸŒ… ๐Ÿงฝ โœ” ๐ŸŽ› โฎ๏ธ Oauth2๏ธโƒฃ โ†” ๐ŸŒโ” ๐Ÿ’ช.
  • ...โ™’๏ธ.

๐Ÿ‘, ๐Ÿ‘† 5๏ธโƒฃ๐Ÿ“† โœ”๏ธ ๐Ÿ“ถ ๐ŸŽฏ โš™๏ธ ๐Ÿ’ผ ๐ŸŒโ” ๐Ÿ‘† ๐Ÿค™ ๐Ÿ’ช โŽ ๐Ÿ› ๏ธ ๐Ÿฉบ ๐ŸŒ (โœ… ๐Ÿญ) โš–๏ธ โš“๏ธ ๐Ÿ”› ๐Ÿ“ณ โšช๏ธโžก๏ธ ๐ŸŒ ๐Ÿ”ข.

๐ŸŽฒ ๐Ÿ—„ โšช๏ธโžก๏ธ โš’ & ๐Ÿ‡จ๐Ÿ‡ป {

๐Ÿ‘† ๐Ÿ’ช ๐Ÿ’ช โš™๏ธ ๐ŸŽ Pydantic โš’ ๐Ÿ”— ๐Ÿ‘† ๐Ÿ— ๐Ÿ—„ & ๐Ÿฉบ โšœ.

๐Ÿ–ผ:

from fastapi import FastAPI
from pydantic_settings import BaseSettings


class Settings(BaseSettings):
    openapi_url: str = "/openapi.json"


settings = Settings()

app = FastAPI(openapi_url=settings.openapi_url)


@app.get("/")
def root():
    return {"message": "Hello World"}

๐Ÿ“ฅ ๐Ÿ‘ฅ ๐Ÿ“ฃ โš’ openapi_url โฎ๏ธ ๐ŸŽ ๐Ÿ”ข "/openapi.json".

& โคด๏ธ ๐Ÿ‘ฅ โš™๏ธ โšซ๏ธ ๐Ÿ•โ” ๐Ÿ— FastAPI ๐Ÿ“ฑ.

โคด๏ธ ๐Ÿ‘† ๐Ÿ’ช โŽ ๐Ÿ—„ (โœ… ๐ŸŽš ๐Ÿฉบ) โš’ ๐ŸŒ ๐Ÿ”ข OPENAPI_URL ๐Ÿ› ๐ŸŽป, ๐Ÿ’–:

$ OPENAPI_URL= uvicorn main:app

<span style="color: green;">INFO</span>:     Uvicorn running on http://127.0.0.1:8000 (Press CTRL+C to quit)

โคด๏ธ ๐Ÿšฅ ๐Ÿ‘† ๐Ÿšถ ๐Ÿ“› /openapi.json, /docs, โš–๏ธ /redoc ๐Ÿ‘† ๐Ÿ”œ ๐Ÿคš 404 Not Found โŒ ๐Ÿ’–:

{
    "detail": "Not Found"
}