Rename html/ and add error message

This commit is contained in:
Tanner Collin 2021-08-20 22:14:57 +00:00
parent 4a0d12971b
commit 08d9de8784
3 changed files with 5 additions and 2 deletions

View File

@ -5,7 +5,7 @@ Guest Book
==========
If you visited my website, please sign my guestbook!
<form action="g/submit" method="POST" accept-charset="UTF-8">
<form action="submit" method="POST" accept-charset="UTF-8">
Your name:
<input name="name">

View File

@ -40,7 +40,7 @@ async def new_message(event):
entry += '\n\n{}\n\n'.format(data['message'])
with open('data/html/index.html', 'a') as f:
with open('data/g/index.html', 'a') as f:
f.write(entry)
await event.reply('Entry added to t0.vc/g')
@ -60,6 +60,9 @@ async def submit(request):
except KeyError:
raise web.HTTPBadRequest(reason='You are missing something.')
if not len(name) or not len(message):
raise web.HTTPBadRequest(reason='You are missing something.')
if len(name) > 50:
raise web.HTTPBadRequest(reason='Name is too long.')
if len(website) > 100: