Initial commit

This commit is contained in:
Nexus 2024-04-17 16:27:58 +01:00
commit a55db863b0
Signed by: nex
GPG key ID: 0FA334385D0B689F
2 changed files with 26 additions and 0 deletions

8
Dockerfile Normal file
View file

@ -0,0 +1,8 @@
FROM python:3-slim
WORKDIR /app
COPY ipserv.py /app
EXPOSE 8000
RUN pip install flask requests gunicorn
CMD ["gunicorn", "-w", "4", "-b", "0.0.0.0", "ipserv:app"]

18
ipserv.py Normal file
View file

@ -0,0 +1,18 @@
import requests
from flask import Flask, request, make_response
app = Flask(__name__)
@app.get("/")
def ip():
if "X-Real-IP" in request.headers:
ip = request.headers["X-Real-IP"]
else:
ip = request.remote_addr
response = requests.get("https://ip.shronk.net/lookup?ip=" + ip)
data = response.json()
data.pop("legalese")
data.pop("source")
data.pop("brexitRequired")
return data, response.status_code