Make python 3.7 compatible
This commit is contained in:
parent
c8fa4d0dad
commit
9f8bc4b9a4
4
main.py
4
main.py
@ -24,7 +24,7 @@ def get_client(request: aiohttp.web.Request):
|
|||||||
raise aiohttp.web.HTTPBadRequest()
|
raise aiohttp.web.HTTPBadRequest()
|
||||||
|
|
||||||
if not model.exists_client(client):
|
if not model.exists_client(client):
|
||||||
print(f'[get_client] model does not know {client=}')
|
#print(f'[get_client] model does not know {client=}')
|
||||||
raise aiohttp.web.HTTPBadRequest()
|
raise aiohttp.web.HTTPBadRequest()
|
||||||
|
|
||||||
return client
|
return client
|
||||||
@ -40,7 +40,7 @@ async def handler(request: aiohttp.web.Request):
|
|||||||
@routes.get(CLIENT_REGEX + '/')
|
@routes.get(CLIENT_REGEX + '/')
|
||||||
async def handler(request: aiohttp.web.Request):
|
async def handler(request: aiohttp.web.Request):
|
||||||
client = get_client(request)
|
client = get_client(request)
|
||||||
print(f"{client=} accessed")
|
#print(f"{client=} accessed")
|
||||||
return aiohttp.web.FileResponse('ui.html')
|
return aiohttp.web.FileResponse('ui.html')
|
||||||
|
|
||||||
@routes.post('/api/token{authtoken}/{method}')
|
@routes.post('/api/token{authtoken}/{method}')
|
||||||
|
5
model.py
5
model.py
@ -6,8 +6,9 @@ import datetime
|
|||||||
import hashlib
|
import hashlib
|
||||||
|
|
||||||
def generate_random_id(_s=set()):
|
def generate_random_id(_s=set()):
|
||||||
while (new_id := base64.b32encode(bytearray(random.randint(0, 0xFF) for _ in range(10)))[:16].decode().lower()) in _s:
|
newid = base64.b32encode(bytearray(random.randint(0, 0xFF) for _ in range(10)))[:16].decode().lower()
|
||||||
pass
|
while (new_id in _s):
|
||||||
|
newid = base64.b32encode(bytearray(random.randint(0, 0xFF) for _ in range(10)))[:16].decode().lower()
|
||||||
_s.add(new_id)
|
_s.add(new_id)
|
||||||
return new_id
|
return new_id
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user