Tôi bắt đầu với cùng một vấn đề như trong this question. Là một trong những câu trả lời cho thấy người ta có thể tránh được vấn đề cụ thể đó bằng cách làm cho ứng dụng chạy mà không cần SSL. Nhưng như Facebook được thiết lập để thực thi https cho các ứng dụng chỉ trong một vài ngày (ngày 01 tháng 10 năm 2011) mà có vẻ như một giải pháp mà sẽ không kéo dài. đầu tiên tôi đã cố gắng để cho phép ssl trong app.run (khoảng dòng 149 trong exampleapp.py
Giống như vậy:.Các sự cố khi tải ứng dụng ví dụ Heroku cho Python chạy cục bộ với SSL
app.run(host='0.0.0.0', port=port, ssl_context='adhoc')
Lúc đầu thử nó thất bại khi khởi động phàn nàn về các module OpenSSL mất tích Tìm thấy một vài gợi ý về cách để sửa chữa. rằng ngoài kia trên mạng, và chọn để làm:
(myapp)$ pip install pyopenssl
Bây giờ không có khiếu nại khi khởi động:
(myapp)$ foreman start
10:35:25 web.1 | started with pid 26934
10:35:26 web.1 | * Running on https://0.0.0.0:5000/
10:35:26 web.1 | * Restarting with reloader
Nhưng sau đó khi cố gắng truy cập vào các ứng dụng:
10:35:31 web.1 | ----------------------------------------
10:35:31 web.1 | Exception happened during processing of request from ('127.0.0.1', 61118)
10:35:31 web.1 | Traceback (most recent call last):
10:35:31 web.1 | File "/usr/local/Cellar/python/2.7.1/lib/python2.7/SocketServer.py", line 284, in _handle_request_noblock
10:35:31 web.1 | self.process_request(request, client_address)
10:35:31 web.1 | File "/usr/local/Cellar/python/2.7.1/lib/python2.7/SocketServer.py", line 310, in process_request
10:35:31 web.1 | self.finish_request(request, client_address)
10:35:31 web.1 | File "/usr/local/Cellar/python/2.7.1/lib/python2.7/SocketServer.py", line 323, in finish_request
10:35:31 web.1 | self.RequestHandlerClass(request, client_address, self)
10:35:31 web.1 | File "/usr/local/Cellar/python/2.7.1/lib/python2.7/SocketServer.py", line 639, in __init__
10:35:31 web.1 | self.handle()
10:35:31 web.1 | File "path_to_myapp/lib/python2.7/site-packages/werkzeug/serving.py", line 189, in handle
10:35:31 web.1 | return rv
10:35:31 web.1 | UnboundLocalError: local variable 'rv' referenced before assignment
10:35:31 web.1 | ----------------------------------------
10:35:31 web.1 | Unhandled exception in thread started by <function inner at 0x10139e050>
10:35:31 web.1 | Traceback (most recent call last):
10:35:31 web.1 | File "path_to_myapp/lib/python2.7/site-packages/werkzeug/serving.py", line 599, in inner
10:35:31 web.1 | passthrough_errors, ssl_context).serve_forever()
10:35:31 web.1 | File "path_to_myapp/lib/python2.7/site-packages/werkzeug/serving.py", line 355, in serve_forever
10:35:31 web.1 | HTTPServer.serve_forever(self)
10:35:31 web.1 | File "/usr/local/Cellar/python/2.7.1/lib/python2.7/SocketServer.py", line 227, in serve_forever
10:35:31 web.1 | self._handle_request_noblock()
10:35:31 web.1 | File "/usr/local/Cellar/python/2.7.1/lib/python2.7/SocketServer.py", line 287, in _handle_request_noblock
10:35:31 web.1 | self.shutdown_request(request)
10:35:31 web.1 | File "/usr/local/Cellar/python/2.7.1/lib/python2.7/SocketServer.py", line 459, in shutdown_request
10:35:31 web.1 | request.shutdown(socket.SHUT_WR)
10:35:31 web.1 | TypeError: shutdown() takes exactly 0 arguments (1 given)
Phải làm gì với điều này? Nó có phải là phiên bản Python sai hay chỉ cho tôi hiểu sai một số điều cơ bản khác?