HTTPS in web.py
HTTPS in web.py
<hh/1344>
(2010-08-27)
Using HTTPS in web.py is easy (provided you have your certificates). Just import the WSGI server class from web.py at the beginning of src/hkweb.py: from web.wsgiserver import CherryPyWSGIServer Then, add this code to the beginning of hkweb.start(): CherryPyWSGIServer.ssl_certificate = "/path/to/your.crt" CherryPyWSGIServer.ssl_private_key = "/path/to/your.key" And that's all. From now on, you can access hkweb via https://localhost:8080. If you need a certificate, use this: openssl genrsa -des3 -out server.key 1024 openssl req -new -key server.key -out server.csr openssl x509 -req -days 365 -in server.csr -signkey server.key -out server.crt mv server.key myserver.key mv server.crt myserver.crt Your browser will warn you about the certificate being invalid, but it will work nonetheless. The relevant Google Groups thread: http://groups.google.com/group/webpy/browse_thread/thread/53a7cdc07af6fcc5
# coding=utf-8 # @Author : zhoujiamu # @Time : 2018/2/8 22:37 import web urls = ('/.*','WebHooks') app = web.application(urls, globals()) class WebHooks: def POST(self): raw_payload = web.data() json_encode = json.loads(raw_payload) if __name__ == '__main__': #app.run() from web.wsgiserver import CherryPyWSGIServer ssl_cert = '/usr/ssl/server.crt' ssl_key = '/usr/ssl/server.key' CherryPyWSGIServer.ssl_certificate = ssl_cert CherryPyWSGIServer.ssl_private_key = ssl_key app.run()