added https option for tornado
now tornado can be called by https
This commit is contained in:
@@ -65,6 +65,11 @@ Here is a complete sample web2py action:
|
|||||||
'http://127.0.0.1:8888',form.vars.message,'mykey','mygroup')
|
'http://127.0.0.1:8888',form.vars.message,'mykey','mygroup')
|
||||||
return form
|
return form
|
||||||
|
|
||||||
|
https is possible too using 'https://127.0.0.1:8888' instead of 'http://127.0.0.1:8888', but need to
|
||||||
|
be started with
|
||||||
|
|
||||||
|
python gluon/contrib/websocket_messaging.py -k mykey -p 8888 -s keyfile.pem -c certfile.pem
|
||||||
|
|
||||||
Acknowledgements:
|
Acknowledgements:
|
||||||
Tornado code inspired by http://thomas.pelletier.im/2010/08/websocket-tornado-redis/
|
Tornado code inspired by http://thomas.pelletier.im/2010/08/websocket-tornado-redis/
|
||||||
|
|
||||||
@@ -194,6 +199,16 @@ if __name__ == "__main__":
|
|||||||
default=False,
|
default=False,
|
||||||
dest='tokens',
|
dest='tokens',
|
||||||
help='require tockens to join')
|
help='require tockens to join')
|
||||||
|
parser.add_option('-s',
|
||||||
|
'--sslkey',
|
||||||
|
default=False,
|
||||||
|
dest='keyfile',
|
||||||
|
help='require ssl keyfile full path')
|
||||||
|
parser.add_option('-c',
|
||||||
|
'--sslcert',
|
||||||
|
default=False,
|
||||||
|
dest='certfile',
|
||||||
|
help='require ssl certfile full path')
|
||||||
(options, args) = parser.parse_args()
|
(options, args) = parser.parse_args()
|
||||||
hmac_key = options.hmac_key
|
hmac_key = options.hmac_key
|
||||||
DistributeHandler.tokens = options.tokens
|
DistributeHandler.tokens = options.tokens
|
||||||
@@ -202,6 +217,10 @@ if __name__ == "__main__":
|
|||||||
(r'/token', TokenHandler),
|
(r'/token', TokenHandler),
|
||||||
(r'/realtime/(.*)', DistributeHandler)]
|
(r'/realtime/(.*)', DistributeHandler)]
|
||||||
application = tornado.web.Application(urls, auto_reload=True)
|
application = tornado.web.Application(urls, auto_reload=True)
|
||||||
http_server = tornado.httpserver.HTTPServer(application)
|
if options.keyfile and options.certfile:
|
||||||
|
ssl_options = dict(certfile=options.certfile, keyfile=options.keyfile)
|
||||||
|
else:
|
||||||
|
ssl_options = None
|
||||||
|
http_server = tornado.httpserver.HTTPServer(application, ssl_options=ssl_options)
|
||||||
http_server.listen(int(options.port), address=options.address)
|
http_server.listen(int(options.port), address=options.address)
|
||||||
tornado.ioloop.IOLoop.instance().start()
|
tornado.ioloop.IOLoop.instance().start()
|
||||||
|
|||||||
Reference in New Issue
Block a user