我试图让我的服务器使用https/ssl连接。我有证书和钥匙。我尝试过在http://webpy.org/cookbook/ssl中使用这个示例,但它仍然使用http而不是https。我的web.py版本是最新的(0.38),但我也尝试使用站点中提供的旧实现,这导致了错误:
Traceback (most recent call last):
File "/path/server.py", line 7, in <module>
from web.wsgiserver.ssl_builtin import BuiltinSSLAdapter
File "/Library/Python/2.7/site-packages/web/wsgiserver/ssl_builtin.py", line 14, in <module>
from cherrypy import wsgiserver
ImportError: cannot import name wsgiserver在队伍中:
from web.wsgiserver.ssl_builtin import BuiltinSSLAdapter有解决办法吗?(我猜不是因为错误,因为它是由于一种适合于较早版本的web.py的使用而产生的,而是用于第一个实现)。
谢谢
编辑:我正在运行的代码:
import sys
import web
from web.wsgiserver import CherryPyWSGIServer
from utils.tools import Tools
from pages.index import index
from pages.search import search
from pages.update_location import update_location
from pages.add_sn_tracking import add_sn_tracking
from pages.edit_sn_tracking import edit_sn_tracking
from pages.add_sheet_tracking import add_sheet_tracking
from pages.edit_sheet_tracking import edit_sheet_tracking
class WebServer:
def __init__(self):
CherryPyWSGIServer.ssl_certificate = r"/Volumes/wlutils/Users/TesterUs/snserver/server.crt"
CherryPyWSGIServer.ssl_private_key = r"/Volumes/wlutils/Users/TesterUs/snserver/server.key"
self.urls = (
'/', 'index',
'/search', 'search',
'/update_location', 'update_location',
'/add_sn_tracking', 'add_sn_tracking',
'/edit_sn_tracking', 'edit_sn_tracking',
'/add_sheet_tracking', 'add_sheet_tracking',
'/edit_sheet_tracking', 'edit_sheet_tracking',
)
# web.config.debug = False
self.app = web.application(self.urls, globals())
self.app.run()
if __name__ == "__main__":
w = WebServer()发布于 2017-03-20 15:09:02
要为SSL设置web.py,只需设置内部CherryPyWSGIServer:
from web.wsgiserver import CherryPyWSGIServer
CherryPyWSGIServer.ssl_certificate = "/file/my.crt"
CherryPyWSGIServer.ssl_private_key = "/file/my.key"在打电话给app = web.application(urls, globals())之前,请先这样做。如果这对您不起作用,那么让我们来探索一下,而不是您正在尝试的pre-v.0.38解决方案,因为它不适用于当前的web.py。
后续行动:似乎使用了较早版本的web.py。一旦更新到0.38+,这个示例就可以工作了。
https://stackoverflow.com/questions/42887071
复制相似问题