Spaces:
Running
Running
app.py
CHANGED
@@ -10,7 +10,7 @@ uvicorn app:app --host 0.0.0.0 --port 10000
|
|
10 |
import os , sys
|
11 |
import datetime , requests , random , logging , time , timeit
|
12 |
import simplejson as json
|
13 |
-
from fastapi import FastAPI
|
14 |
from fastapi.responses import PlainTextResponse , HTMLResponse , Response , JSONResponse
|
15 |
# from fastapi import Request
|
16 |
from starlette.requests import Request
|
@@ -48,6 +48,7 @@ BOT_AGENTS = [
|
|
48 |
|
49 |
# MONGODB-ATLAS SETUP
|
50 |
MONGOATLAS_URI = os.environ.get('MONGOATLAS_URI') or None
|
|
|
51 |
|
52 |
##############################################################################
|
53 |
#
|
@@ -69,7 +70,11 @@ console_logger.setFormatter(logging.Formatter('%(message)s'))
|
|
69 |
logger.addHandler(console_logger)
|
70 |
|
71 |
if not MONGOATLAS_URI:
|
72 |
-
logger.warning('
|
|
|
|
|
|
|
|
|
73 |
|
74 |
# Disable urllib3 warnings (sent by requests)
|
75 |
# requests.packages.urllib3.disable_warnings()
|
@@ -102,7 +107,7 @@ def remote_ip(request:Request):
|
|
102 |
return PlainTextResponse(client_host , 200)
|
103 |
|
104 |
@app.get("/task/faa_scrap_sold_listings_featured")
|
105 |
-
def faa_scrap_sold_listings_featured_local():
|
106 |
|
107 |
global proxies
|
108 |
|
@@ -115,6 +120,11 @@ def faa_scrap_sold_listings_featured_local():
|
|
115 |
if not MONGOATLAS_URI:
|
116 |
return PlainTextResponse("ERROR: MONGOATLAS_URI is undefined" , status_code=500)
|
117 |
|
|
|
|
|
|
|
|
|
|
|
118 |
cnt_dbs = 4
|
119 |
|
120 |
headers = {
|
|
|
10 |
import os , sys
|
11 |
import datetime , requests , random , logging , time , timeit
|
12 |
import simplejson as json
|
13 |
+
from fastapi import FastAPI , Request
|
14 |
from fastapi.responses import PlainTextResponse , HTMLResponse , Response , JSONResponse
|
15 |
# from fastapi import Request
|
16 |
from starlette.requests import Request
|
|
|
48 |
|
49 |
# MONGODB-ATLAS SETUP
|
50 |
MONGOATLAS_URI = os.environ.get('MONGOATLAS_URI') or None
|
51 |
+
AK = os.environ.get('AK') or None
|
52 |
|
53 |
##############################################################################
|
54 |
#
|
|
|
70 |
logger.addHandler(console_logger)
|
71 |
|
72 |
if not MONGOATLAS_URI:
|
73 |
+
logger.warning('Could not read the database URI')
|
74 |
+
|
75 |
+
if not MONGOATLAS_URI:
|
76 |
+
logger.warning('Could not read the access key')
|
77 |
+
|
78 |
|
79 |
# Disable urllib3 warnings (sent by requests)
|
80 |
# requests.packages.urllib3.disable_warnings()
|
|
|
107 |
return PlainTextResponse(client_host , 200)
|
108 |
|
109 |
@app.get("/task/faa_scrap_sold_listings_featured")
|
110 |
+
def faa_scrap_sold_listings_featured_local(request:Request):
|
111 |
|
112 |
global proxies
|
113 |
|
|
|
120 |
if not MONGOATLAS_URI:
|
121 |
return PlainTextResponse("ERROR: MONGOATLAS_URI is undefined" , status_code=500)
|
122 |
|
123 |
+
access_key = request.args.get('AK')
|
124 |
+
if access_key != AK:
|
125 |
+
return PlainTextResponse("ERROR: Unauthorized call" , status_code=401)
|
126 |
+
|
127 |
+
|
128 |
cnt_dbs = 4
|
129 |
|
130 |
headers = {
|