Update app.py
Browse files
app.py
CHANGED
@@ -1,12 +1,13 @@
|
|
1 |
from asyncio import Queue, create_task
|
2 |
from contextlib import asynccontextmanager
|
3 |
-
from json import dumps,
|
4 |
from pathlib import Path
|
5 |
-
|
|
|
6 |
from fastapi import FastAPI, HTTPException
|
7 |
-
from fastapi.responses import
|
|
|
8 |
from uvicorn import run as uvicorn_run
|
9 |
-
from apscheduler.schedulers.asyncio import AsyncIOScheduler
|
10 |
|
11 |
scheduler = AsyncIOScheduler()
|
12 |
try:
|
@@ -89,7 +90,7 @@ async def get_proxies():
|
|
89 |
if collected_json.exists():
|
90 |
return loads(collected_json.read_text())
|
91 |
else:
|
92 |
-
return JSONResponse({"error": "not ready yet"}, status_code=204)
|
93 |
|
94 |
|
95 |
@app.get('/')
|
@@ -98,4 +99,4 @@ async def read_root():
|
|
98 |
|
99 |
|
100 |
if __name__ == "__main__":
|
101 |
-
uvicorn_run(app, host='
|
|
|
1 |
from asyncio import Queue, create_task
|
2 |
from contextlib import asynccontextmanager
|
3 |
+
from json import dumps, loads
|
4 |
from pathlib import Path
|
5 |
+
|
6 |
+
from apscheduler.schedulers.asyncio import AsyncIOScheduler
|
7 |
from fastapi import FastAPI, HTTPException
|
8 |
+
from fastapi.responses import JSONResponse, PlainTextResponse
|
9 |
+
from proxybroker import Broker
|
10 |
from uvicorn import run as uvicorn_run
|
|
|
11 |
|
12 |
scheduler = AsyncIOScheduler()
|
13 |
try:
|
|
|
90 |
if collected_json.exists():
|
91 |
return loads(collected_json.read_text())
|
92 |
else:
|
93 |
+
return JSONResponse({"error": "Proxy list is not ready yet."}, status_code=204)
|
94 |
|
95 |
|
96 |
@app.get('/')
|
|
|
99 |
|
100 |
|
101 |
if __name__ == "__main__":
|
102 |
+
uvicorn_run(app, host='0.0.0.0', port=7860, timeout_keep_alive=90)
|