Reputation: 151
How can I get data (html input) using python-tornado.
python code is this:
import tornado.web
import tornado.ioloop
import tornado.httpserver
class MainHandler(tornado.web.RequestHandler):
def get(self):
self.render("index.html")
def post(self):
title = self.get_argument("title")
self.render("second.html")
app = tornado.web.Application([
(r"/", MainHandler),
])
http_server = tornado.httpserver.HTTPServer(app)
http_server.listen(8080)
tornado.ioloop.IOLoop.instance().start()
and html source code is this:
<!Doctype html>
<html>
<body>
<form method="post"></form>
<div style="margin-bottom:5px">
<input name="title" type="text"/>
</div>
<div>
<input type="submit"/>
</div>
</form>
</body>
</html>
Upvotes: 1
Views: 2558
Reputation:
Try something like this guy has Stack Overflow
class MyHandler(tornado.web.RequestHandler):
def post(self):
name = self.get_argument("Name", "")
index = self.get_argument("Index","")
.... code for updating MongoDB
Upvotes: 1