Return information about the request
This commit is contained in:
parent
44d851b14f
commit
f4ed6c2d6f
|
@ -0,0 +1,2 @@
|
|||
__pycache__/
|
||||
*.pyc
|
|
@ -0,0 +1,21 @@
|
|||
from fastapi import FastAPI, Header, Request
|
||||
|
||||
app = FastAPI()
|
||||
|
||||
@app.get("/")
|
||||
def root(request: Request):
|
||||
return {
|
||||
"method": request.method,
|
||||
"url": {
|
||||
"url": request.url._url,
|
||||
"scheme": request.url.scheme,
|
||||
"hostname": request.url.hostname,
|
||||
"port": request.url.port,
|
||||
"path": request.url.path,
|
||||
},
|
||||
"headers": request.headers,
|
||||
"client": {
|
||||
"ip-address": request.client.host,
|
||||
"port": request.client.port,
|
||||
},
|
||||
}
|
|
@ -0,0 +1,17 @@
|
|||
anyio==3.5.0
|
||||
asgiref==3.5.0
|
||||
click==8.0.3
|
||||
fastapi==0.73.0
|
||||
h11==0.13.0
|
||||
httptools==0.3.0
|
||||
idna==3.3
|
||||
pydantic==1.9.0
|
||||
python-dotenv==0.19.2
|
||||
PyYAML==6.0
|
||||
sniffio==1.2.0
|
||||
starlette==0.17.1
|
||||
typing_extensions==4.0.1
|
||||
uvicorn==0.17.1
|
||||
uvloop==0.16.0
|
||||
watchgod==0.7
|
||||
websockets==10.1
|
Loading…
Reference in New Issue