I'm completely new to the bottle framework and its methods. As a homework, my constructor wanted me to build a basic forum which should be able to accomplish simple posting, deleting, sorting, etc. messages.
Just, post a message, delete it by inserting its number and go back to the messages page. You will see a "None" message.
This is the part of the site that deletes the message:
@bottle.route("/erasedlogs" , method="POST")
def erased_logs():
global message_depo
integer=bottle.request.POST.get('number')
del message_depo[int(integer)]
i=0
while i < len(message_depo):
content=content + '<p> '+ message_depo[i]+ ' :comment' + str(i) + '</p> \n'
i=i+1
content=content + '<p> <a style="color:red" href="/message">See current messages.</a></p> \n '
And this is the page which reserves the messages:
@bottle.route("/message", method="ANY")
def get_message():
global message_depo
message=bottle.request.POST.get('message')
time_message=datetime.datetime.now()
message_log=str(message)+ " = " + str(time_message)
message_depo.append(message_log)
i=0
while i< len(message_depo):
content=content + ' <p> '+ message_depo[i]+ ' <strong>:comment</strong> ' + str(i) + '</p> \n'
When I hit the link "see current messages" in the first block of code it creates a meaningless (at least for me) "None" message.
Could someone simply explain why it happens and how I get rid of it?
You're not returning any content. In both of your functions, you need to add this line:
return content