I downloaded the sample project and started it myself. I think I have made some progress.
Firstly, the original MainHandler is not able to handle the POST request. According to the code, it processes a request like /room/1 , /room/2 .
Secondly, I think that you are trying to simulate a login form. However, the GET method and /login as the endpoint are used in the login form:
<form class="form-inline" action="/login" method="get">
I assume that you will also put your form in index.html, whose URL is actually /login (if not logged in) or /room/X (logged in). Thus, you probably end up in LoginHandler.
Third, when I add a mail method to MainHandler and send a POST request to /room/1 , it actually works and triggers a 500 Internal Error.
I use curl to check out a few cases. If you try to send a POST request to MainHandler to / , it doesn't even respond! Because, as mentioned earlier, get is defined as get (self, room = None). It accepts only /room/X
If you try it on /room or /login , the answer will be 405 Method Not Allowed .
If you want POST to be available for /login , the easiest way is to add POST to LoginHandler as follows:
@tornado.web.asynchronous def post(self): self.get()
source share