flask 搭建ssl接口


from flask import Flask,jsonify
app = Flask(__name__)
#app.config['SERVER_NAME'] = 'example.com'

@app.route('/')
def hello_world():
data = {'data':[{'name': 'test', 'image': 'https://img3.doubanio.com/icon/u1074067-64.jpg', 'update': 1}]}
return jsonify(data)

if __name__ == '__main__':
app.run( debug=True, port=5000, ssl_context=('server.crt','server.key'))

pip install pyopenssl 用这个第三方包的话,
ssl_context=('server.crt','server.key') 替换成
ssl_context='adhoc'即可


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM