Compare commits
No commits in common. "master" and "f4ed6c2d6f4ece463e35263de22faf85563c7702" have entirely different histories.
master
...
f4ed6c2d6f
34
main.py
34
main.py
@ -1,14 +1,10 @@
|
|||||||
import platform
|
|
||||||
import socket
|
|
||||||
|
|
||||||
from fastapi import FastAPI, Header, Request
|
from fastapi import FastAPI, Header, Request
|
||||||
import netifaces
|
|
||||||
|
|
||||||
app = FastAPI()
|
app = FastAPI()
|
||||||
|
|
||||||
@app.get("/")
|
@app.get("/")
|
||||||
def root(request: Request, x_full_response: bool = Header(False)):
|
def root(request: Request):
|
||||||
response = {
|
return {
|
||||||
"method": request.method,
|
"method": request.method,
|
||||||
"url": {
|
"url": {
|
||||||
"url": request.url._url,
|
"url": request.url._url,
|
||||||
@ -22,30 +18,4 @@ def root(request: Request, x_full_response: bool = Header(False)):
|
|||||||
"ip-address": request.client.host,
|
"ip-address": request.client.host,
|
||||||
"port": request.client.port,
|
"port": request.client.port,
|
||||||
},
|
},
|
||||||
"host": {
|
|
||||||
"hostname": platform.node(),
|
|
||||||
"fqdn": socket.getfqdn(),
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
if not x_full_response:
|
|
||||||
return response
|
|
||||||
|
|
||||||
interfaces = {}
|
|
||||||
for interface in netifaces.interfaces():
|
|
||||||
interfaces[interface] = []
|
|
||||||
for link in netifaces.ifaddresses(interface).values():
|
|
||||||
for group in link:
|
|
||||||
interfaces[interface].append(group['addr'])
|
|
||||||
|
|
||||||
response["host"].update({
|
|
||||||
"python": platform.python_version(),
|
|
||||||
|
|
||||||
"os": {
|
|
||||||
"system": platform.system(),
|
|
||||||
"release": platform.release(),
|
|
||||||
"version": platform.version(),
|
|
||||||
},
|
|
||||||
|
|
||||||
"ip-addresses": interfaces,
|
|
||||||
})
|
|
||||||
return response
|
|
||||||
|
@ -2,11 +2,9 @@ anyio==3.5.0
|
|||||||
asgiref==3.5.0
|
asgiref==3.5.0
|
||||||
click==8.0.3
|
click==8.0.3
|
||||||
fastapi==0.73.0
|
fastapi==0.73.0
|
||||||
gunicorn==20.1.0
|
|
||||||
h11==0.13.0
|
h11==0.13.0
|
||||||
httptools==0.3.0
|
httptools==0.3.0
|
||||||
idna==3.3
|
idna==3.3
|
||||||
netifaces==0.11.0
|
|
||||||
pydantic==1.9.0
|
pydantic==1.9.0
|
||||||
python-dotenv==0.19.2
|
python-dotenv==0.19.2
|
||||||
PyYAML==6.0
|
PyYAML==6.0
|
||||||
|
Loading…
x
Reference in New Issue
Block a user