请帮助我创建HTTPS龙卷风服务器我当前的代码Python3不起作用
import os, socket, ssl, pprint, tornado.ioloop, tornado.web, tornado.httpserver from tornado.tcpserver import TCPServer class getToken(tornado.web.RequestHandler): def get(self): self.write("hello") application = tornado.web.Application([ (r'/', getToken), ]) # implementation for SSL http_server = tornado.httpserver.HTTPServer(application) TCPServer(ssl_options={ "certfile": os.path.join("/var/pyTest/keys/", "ca.csr"), "keyfile": os.path.join("/var/pyTest/keys/", "ca.key"), }) if __name__ == '__main__': #http_server.listen(8888) http_server = TCPServer() http_server.listen(443) tornado.ioloop.IOLoop.instance().start()
HTTPS对我来说很重要,请帮忙
无需使用TCPServer。
TCPServer
请尝试以下操作:
import tornado.httpserver import tornado.ioloop import tornado.web class getToken(tornado.web.RequestHandler): def get(self): self.write("hello") application = tornado.web.Application([ (r'/', getToken), ]) if __name__ == '__main__': http_server = tornado.httpserver.HTTPServer(application, ssl_options={ "certfile": "/var/pyTest/keys/ca.csr", "keyfile": "/var/pyTest/keys/ca.key", }) http_server.listen(443) tornado.ioloop.IOLoop.instance().start()