document

인프라/FastAPI

[FastAPI] Docs Bookmark - Tutorial 3

python 3.6 ~ python 3.8 Fastapi 0.95.0 Dependencies ⌾ What is "Dependency Injection" ⌵ 코드의 작동 및 사용에 필요한 의존성을 선언할 방법이 있음을 의미 ⌵ 반복적인 logic, DB connection 공유, 보안|인증|역할 요건 등에 유용하다 First Steps ⌾ Create a dependency or dependable & Import Depends ⌾ Declare the dependency, in the "dependant" Depends에는 single 파라미터만 지정하며 해당 파라미터는 함수와 유사하다 ... from fastapi import Depends, FastAPI async def common_paramete..

인프라/FastAPI

[FastAPI] Docs Bookmark - Tutorial 2

python 3.6 ~ python 3.8 Fastapi 0.95.0 Cookie Parameters ⌾ import Cookie Cookie로 선언하지 않으면, 쿼리 파라미터로 인식된다 from typing import Annotated from fastapi import Cookie, FastAPI ... @app.get("/items/") async def read_items(ads_id: Annotated[str | None, Cookie()] = None): return {"ads_id": ads_id} Header Parameters ⌾ import Header from fastapi import FastAPI, Header ... @app.get("/items/") async def read..

인프라/FastAPI

[FastAPI] Docs Bookmark - Tutorial 1

Python 3.6+ ~ Python 3.8 Fastapi 0.95.0 Intro ⌾ Run the code uvicorn main:app --reload --host 0.0.0.0 --port 8000 # main: the file main.py # app: the object created inside of main.py with the line app=FastAPI() Command line options Uvicorn An ASGI web server, for Python. Introduction Uvicorn is an ASGI web server implementation for Python. Until recently Python has lacked a minimal low-level ser..

콩대생
'document' 태그의 글 목록