🐍 FastAPI built-in API docs

FastAPI has two documentations: by swagger-ui (yourfastapiurl:port/docs) by redoc (yourfastapiurl:port/redoc) from fastapi import FastAPI app = FastAPI() @app.get("/") async def root(): return {"result": "It's working"} @app.get("/ise/{mac_address}") async def ise_search_mac_address(mac_address): return {"Search MAC": mac_address} @app.get("/{mode}/ise") async def ise_mode(mode): if mode == 'dev': return {'result': "Working with Dev ISE"} return {'result': "Working with Prod ISE"} http://127.0.0.1:8089/docs/ Also you can try it right there: http://127.0.0.1:8089/redoc/ And for sure, great FastAPI Documentation itself: here

November 4, 2022 Β· 1 min Β· Dmitry Golovach

🐍 FastAPI Parameters

A quick note about how to pass parameters @app.get("/ise/{mac_address}") async def ise_search_mac_address(mac_address): return {"Search MAC": mac_address} Another example: @app.get("/{mode}/ise") async def ise_mode(mode): if mode == 'dev': return {'result': "Working with Dev ISE"} return {'result': "Working with Prod ISE"}

November 1, 2022 Β· 1 min Β· Dmitry Golovach

🐍 FastAPI Quick Start

Short and easy FastAPI startup for a quick playground and testing. pip install fastapi pip install uvicorn – main.py – from fastapi import FastAPI app = FastAPI() @app.get("/") def read_root(): return {"Hello": "World"} @app.get("/hello") def read_root(): return {"Hello": "Hello"} To start using uvicorn: uvicorn app.main:app --host 127.0.0.1 --port 8089

October 31, 2022 Β· 1 min Β· Dmitry Golovach

🐍 FastAPI Background Tasks

Nice, useful, and easy-to-use feature in FastAPI. It allows responding to the client and doing whatever needs to be done after the request, the client doesn’t have to wait for the operation to complete. For example, get an API request, respond to the client right away, do the job and send a notification once it’s done as a separate event.

October 28, 2022 Β· 1 min Β· Dmitry Golovach