Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion app/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ async def get_spocs(self, session: ClientSession):
targeting['country'] = self.geolocation.get_country(geo)
targeting['region'] = self.geolocation.get_region(geo)
except Exception as e:
logging.warning("Could not target based on geolocation. {0}".format(str(e)))
# logging.warning("Could not target based on geolocation. {0}".format(str(e)))
Comment thread
dmueller marked this conversation as resolved.
Outdated
pass

if self.country:
targeting['country'] = self.country
Expand Down
23 changes: 14 additions & 9 deletions app/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@

import uvicorn
from starlette.responses import JSONResponse
from fastapi import FastAPI, Request
from starlette.requests import ClientDisconnect
from starlette.status import HTTP_204_NO_CONTENT
from fastapi import FastAPI, Request, Response

from app.adzerk.api import Api as AdZerk
from app.client import Client
Expand Down Expand Up @@ -43,14 +45,17 @@ async def lifespan(_: FastAPI) -> None:

@app.post('/spocs')
async def get_spocs(request: Request):
required_params = set(['version', 'consumer_key', 'pocket_id'])
optional_params = set(['site', 'placements', 'country', 'region'])
req_params = await __get_request_params(request)
if request.client is not None:
client_host = request.client.host
else:
client_host = ""
return await call(client_host, req_params, required_params, optional_params=optional_params)
try:
required_params = set(['version', 'consumer_key', 'pocket_id'])
optional_params = set(['site', 'placements', 'country', 'region'])
req_params = await __get_request_params(request)
if request.client is not None:
client_host = request.client.host
else:
client_host = ""
return await call(client_host, req_params, required_params, optional_params=optional_params)
except ClientDisconnect:
return Response(status_code=HTTP_204_NO_CONTENT)
Comment thread
dmueller marked this conversation as resolved.
Outdated


@app.delete('/user')
Expand Down