1
如何使用python-tornado獲取數據(html輸入)。如何使用python龍捲風從html獲取數據
Python代碼是這樣的:
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()
和HTML源代碼是這樣的:
<!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>