|
|
import subprocess |
|
|
import sys |
|
|
|
|
|
|
|
|
def install_dependencies(): |
|
|
subprocess.run([sys.executable, "-m", "pip", "install", "--upgrade", "fastapi", "uvicorn", "httpx"], check=True) |
|
|
|
|
|
try: |
|
|
import fastapi |
|
|
import uvicorn |
|
|
import httpx |
|
|
except ImportError: |
|
|
install_dependencies() |
|
|
import fastapi |
|
|
import uvicorn |
|
|
import httpx |
|
|
|
|
|
from fastapi import FastAPI, Response |
|
|
from fastapi.responses import PlainTextResponse |
|
|
|
|
|
app = FastAPI() |
|
|
|
|
|
|
|
|
@app.get("/ips.txt", response_class=PlainTextResponse) |
|
|
async def get_ips(): |
|
|
url = "http://207.180.209.185:5000/ips.txt" |
|
|
try: |
|
|
async with httpx.AsyncClient(timeout=5.0) as client: |
|
|
response = await client.get(url) |
|
|
response.raise_for_status() |
|
|
return Response(content=response.text, media_type="text/plain") |
|
|
except httpx.RequestError as e: |
|
|
return Response(content=f"Error fetching data: {str(e)}", media_type="text/plain", status_code=500) |
|
|
|