diff --git a/index.html b/index.html index 62db2a7..bac4d3a 100644 --- a/index.html +++ b/index.html @@ -10,22 +10,16 @@ this is the base site -Log in -
- - + + diff --git a/main.py b/main.py index d1e507e..27f3b8c 100644 --- a/main.py +++ b/main.py @@ -1,5 +1,6 @@ import aiohttp.web import traceback +import urllib.parse from model import Model @@ -31,7 +32,7 @@ def get_client(request: aiohttp.web.Request): async def handler(request: aiohttp.web.Request): # this handler prevents people missing trailing slashes client = get_client(request) - raise aiohttp.web.HTTPFound(f"/{client}/") + raise aiohttp.web.HTTPFound(f"{client}/") @routes.get(CLIENT_REGEX + '/') @@ -95,19 +96,14 @@ async def handler(request): return aiohttp.web.FileResponse('index.html') -@routes.post('/newclient') +@routes.get('/register/{username}') async def handler(request): model = request.app['model'] - data = await request.json() - username = data.get("username") - print(f"{username=}") - if username: - client = model.create_client(username) - print(f"werked?") - raise aiohttp.web.HTTPFound(f"/{client}/") - print(f"werked?") - else: - raise aiohttp.web.HTTPFound(f"/newclient") + username = request.match_info.get('username', 'Joe') + username = urllib.parse.unquote(username) + + client = model.create_client(username) + raise aiohttp.web.HTTPFound(f"/{client}/") if __name__ == '__main__':