Пример to-do приложения с сайта разбираю.
Даже когда указываю принудительно запросы через POST, все равно идут GET запросы.
Подскажите как исправить?
@route("/new", method=['POST'])
def new_item():
"""
Add a new TODO item
"""
if request.forms.get("save", ""):
new = request.forms.get("task", "")
conn = sqlite3.connect("todo.db")
c = conn.cursor()
c.execute("INSERT INTO todo (task,status) VALUES (?,?)", (new,1))
new_id = c.lastrowid
conn.commit()
c.close()
redirect("/")
else:
return template("new_task.tpl")
Bottle v0.12.13 server starting up (using WSGIRefServer())...
Listening on http://127.0.0.1:8080/
Hit Ctrl-C to quit.
127.0.0.1 - - [10/Feb/2017 09:35:11] "GET /new HTTP/1.1" 405 736
127.0.0.1 - - [10/Feb/2017 09:35:12] "GET /new HTTP/1.1" 405 736
new_task.tpl
<p>Add a new task to the ToDo list:</p>
<form action="/new" method="POST">
<input type="text" size="100" maxlength="100" name="task">
<input type="submit" name="save" value="save">
</form>
А в браузере вообще:
Error: 405 Method Not Allowed
Sorry, the requested URL 'http://127.0.0.1:8080/new' caused an error:
Method not allowed.