mirror of
https://github.com/nexy7574/LCC-bot.git
synced 2024-09-19 18:16:34 +01:00
Add web-verification
This commit is contained in:
parent
f2780d1f44
commit
6919bc3f15
2 changed files with 3 additions and 2 deletions
1
main.py
1
main.py
|
@ -100,6 +100,7 @@ if __name__ == "__main__":
|
|||
app,
|
||||
host=getattr(config, "HTTP_HOST", "127.0.0.1"),
|
||||
port=getattr(config, "HTTP_PORT", 3762),
|
||||
loop="asyncio",
|
||||
**getattr(config, "UVICORN_CONFIG", {})
|
||||
)
|
||||
server = uvicorn.Server(http_config)
|
||||
|
|
|
@ -112,7 +112,7 @@ async def authenticate(req: Request, code: str = None, state: str = None):
|
|||
|
||||
# Now send a request to https://ip-api.com/json/{ip}?fields=17136
|
||||
response = app.state.http.get(
|
||||
f"https://ip-api.com/json/{req.client.host}?fields=17136"
|
||||
f"http://ip-api.com/json/{req.client.host}?fields=17136"
|
||||
)
|
||||
if response.status_code != 200:
|
||||
raise HTTPException(
|
||||
|
@ -123,7 +123,7 @@ async def authenticate(req: Request, code: str = None, state: str = None):
|
|||
if data["status"] != "success":
|
||||
raise HTTPException(
|
||||
status_code=500,
|
||||
detail="Failed to get IP data."
|
||||
detail=f"Failed to get IP data for {req.client.host}: {data}."
|
||||
)
|
||||
|
||||
# Now we can update the student entry with this data
|
||||
|
|
Loading…
Reference in a new issue