SSLError: Can't connect to HTTPS URL because the SSL module is not available on google app engine

后端 未结 3 1923
北荒
北荒 2021-01-01 14:37

Want to use wechat sdk to create menu

WeChat.create_menu({
     \"button\":[
     {    
          \"type\":\"click\",
          \"name\":\"Daily Song\",
            


        
3条回答
  •  感动是毒
    2021-01-01 15:23

    This blog post details a solution. From the blog post:

    The problem is GAE has a “whitelist” of select standard libraries. SSL (_ssl, _socket) is not one of them. So, we need to tweak the sandbox environment (dangerous) carefully. The below code uses the standard Python socket library instead of the GAE-provided in the development environment. Modify [or create] appengine_config.py:

    import os
    
    # Workaround the dev-environment SSL
    #   http://stackoverflow.com/q/16192916/893652
    if os.environ.get('SERVER_SOFTWARE', '').startswith('Development'):
        import imp
        import os.path
        from google.appengine.tools.devappserver2.python import sandbox
    
        sandbox._WHITE_LIST_C_MODULES += ['_ssl', '_socket']
        # Use the system socket.
        psocket = os.path.join(os.path.dirname(os.__file__), 'socket.py')
        imp.load_source('socket', psocket)
    

提交回复
热议问题