Init Commit
This commit is contained in:
9
Dockerfile
Normal file
9
Dockerfile
Normal file
@@ -0,0 +1,9 @@
|
||||
FROM python:3.12-slim
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
COPY . .
|
||||
|
||||
RUN pip install -r requirements.txt
|
||||
|
||||
CMD ["python3","main.py"]
|
||||
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)
|
||||
14
requirements.txt
Normal file
14
requirements.txt
Normal file
@@ -0,0 +1,14 @@
|
||||
annotated-doc==0.0.4
|
||||
annotated-types==0.7.0
|
||||
anyio==4.12.1
|
||||
click==8.3.1
|
||||
exceptiongroup==1.3.1
|
||||
fastapi==0.128.0
|
||||
h11==0.16.0
|
||||
idna==3.11
|
||||
pydantic==2.12.5
|
||||
pydantic_core==2.41.5
|
||||
starlette==0.50.0
|
||||
typing-inspection==0.4.2
|
||||
typing_extensions==4.15.0
|
||||
uvicorn==0.40.0
|
||||
Reference in New Issue
Block a user