mirror of
https://github.com/fastapi/fastapi.git
synced 2026-05-06 14:47:05 -04:00
📝 Add docs for using the Starlette Request directly (#25)
Add docs for using the Starlette Request directly
This commit is contained in:
committed by
Sebastián Ramírez
parent
293ebd7cc2
commit
febf8e7341
10
docs/src/using_request_directly/tutorial001.py
Normal file
10
docs/src/using_request_directly/tutorial001.py
Normal file
@@ -0,0 +1,10 @@
|
||||
from fastapi import FastAPI
|
||||
from starlette.requests import Request
|
||||
|
||||
app = FastAPI()
|
||||
|
||||
|
||||
@app.get("/items/{item_id}")
|
||||
def read_root(item_id: str, request: Request):
|
||||
client_host = request.client.host
|
||||
return {"client_host": client_host, "item_id": item_id}
|
||||
Reference in New Issue
Block a user