代码之家  ›  专栏  ›  技术社区  ›  kloop

使用flask运行ssl\u context='adhoc'

  •  0
  • kloop  · 技术社区  · 5 年前

    我想通过https运行一个flask应用程序(目前正在通过http运行)。

    https://gist.github.com/vpack/2d5f3f89affcc58dac462edbfdd5c119 ,似乎需要将ssl\u context='adhoc'添加到烧瓶的执行中应用程序运行使用临时证书。

    我的代码大致如下

    from flask_runner import Runner
    from forms import InputForm
    
    app = Flask(__name__)
    app.config.from_object('config')
    
    runner = Runner(app)
    handler = RotatingFileHandler('log.log', maxBytes=10000, backupCount=1)
    handler.setLevel(logging.DEBUG)
    formatter = logging.Formatter("%(asctime)s - %(message)s")
    handler.setFormatter(formatter)
    app.logger.addHandler(handler)
    app.logger.setLevel(logging.DEBUG)
    runner.run()
    

    (请注意,这不是一个MWE,因为我的代码更复杂,我不知道如何将事物彼此分开)。

    现在,我想我需要将ssl\u context='adhoc'添加到跑步者。跑步()命令,但我得到一个错误,即此参数未知:

    Traceback (most recent call last):
      File "app.py", line 67, in <module>
        runner.run(ssl_context='adhoc')
    TypeError: run() got an unexpected keyword argument 'ssl_context'
    

    我应该提到我使用python3运行这个python脚本应用程序类型.

    0 回复  |  直到 5 年前