私は竜巻、Pythonを使用して小さなWebアプリケーションを作成しています。以下は私のコードです。私は、2つのテキストフィールドを持つpythonのhtmlフォームを持っています、今私は入力フォームを取得し、redisに格納したいと思います。
私の質問 -竜巻のpythonを使用してユーザーの入力データを赤字に保存する方法
- にはどうすれば接続が私のPythonスクリプトから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モジュール、メソッドのredisドキュメント、POST処理に関する竜巻のドキュメントはどうですか? –