我正在写一个使用龙卷风,python的小型web应用程序,下面是我的代码。我有一个带有2个文本字段的Python表单,现在我想要输入文本字段并存储在redis中。
我的问题 -如何使用龙卷风python保存用户输入数据redis
- 我如何连接到从我的python脚本的Redis?
- 如何将传入的用户输入存储到redis中?
示例代码将不胜感激。
import tornado.httpserver
import tornado.ioloop
import tornado.options
import tornado.web
from tornado.options import define, options
define("port", default=8888, help="run on the given port", type=int)
class MainHandler(tornado.web.RequestHandler):
def get(self):
self.write('<html><body><form action="/" method="post">'
'<p>Please enter the Key Value pair for redis.</p>'
'<input type="text" **name="key"** value="type key here">'
'<input type="text" **name="value"** value="type value here">'
'<input type="submit" value="Submit Key Value">'
'</form></body></html>')
def main():
tornado.options.parse_command_line()
application = tornado.web.Application([
(r"/", MainHandler),
])
http_server = tornado.httpserver.HTTPServer(application)
http_server.listen(options.port)
tornado.ioloop.IOLoop.instance().start()
if __name__ == "__main__":
main()
如何连接到redis的python redis模块,有关POST处理的方法和龙卷风文档的redis文档? – 2012-03-16 22:57:56