@@ 34,7 34,8 @@ async def fetch_pw(password: str) -> Dict[str, Any]:
await conn.close()
if not results:
- return {}
+ return {'hash': password_hash,
+ 'occurences': 0}
return dict(results[0])
@@ 49,22 50,22 @@ def handle_json_error(
raise
except Exception as ex:
return web.json_response(
- {"status": "failed", "reason": str(ex)}, status=400
+ {'status': 'failed', 'reason': str(ex)}, status=400
)
return handler
-@router.get("/")
+@router.get('/')
@handle_json_error
async def index(request: web.Request) -> web.Response:
- return web.json_response({"status": 200})
+ return web.json_response({'status': 200})
-@router.get("/api/{password}")
+@router.get('/api/{password}')
@handle_json_error
async def api_get_post(request: web.Request) -> web.Response:
- password = request.match_info["password"]
+ password = request.match_info['password']
db_ret = await fetch_pw(password)
return web.json_response(
{'status': 'ok', 'password': password, 'data': db_ret})