Init Commit
This commit is contained in:
24
main.py
Normal file
24
main.py
Normal file
@@ -0,0 +1,24 @@
|
||||
from fastapi import FastAPI, Request
|
||||
from pydantic import BaseModel
|
||||
import uvicorn
|
||||
|
||||
app = FastAPI()
|
||||
|
||||
class IPResponse(BaseModel):
|
||||
your_public_ip: str
|
||||
port: str
|
||||
msg: str
|
||||
|
||||
@app.get("/", response_model=IPResponse)
|
||||
def my_ip(request: Request):
|
||||
client_ip = request.headers.get("X-Real-IP") or request.headers.get("X-Forwarded-For") or request.client.host
|
||||
client_port = request.headers.get("X-Forwarded-Port") or str(request.client.port)
|
||||
|
||||
return {
|
||||
"your_public_ip": client_ip,
|
||||
"port": client_port,
|
||||
"msg": "abbas be mole"
|
||||
}
|
||||
|
||||
if __name__ == "__main__":
|
||||
uvicorn.run(app, host="0.0.0.0", port=1000)
|
||||
Reference in New Issue
Block a user