Compare commits

..

4 Commits

Author SHA1 Message Date
08d9de8784 Rename html/ and add error message 2021-08-20 22:14:57 +00:00
4a0d12971b Rename main.py to t0sig.py 2021-08-20 21:52:08 +00:00
95720ce0db Rename guestbook.html to index.html 2021-08-20 21:46:30 +00:00
9b50602873 Keep data/html 2021-08-20 21:45:01 +00:00
3 changed files with 5 additions and 2 deletions

0
data/g/.gitkeep Normal file
View File

View File

@@ -5,7 +5,7 @@ Guest Book
========== ==========
If you visited my website, please sign my guestbook! 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: Your name:
<input name="name"> <input name="name">

View File

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