赞
踩
先上代码
from flask import Flask
from flask_restful import Resource, Api
app = Flask(__name__)
api = Api(app)
class HelloWorld(Resource):
def get(self):
return {'hello': 'world'}
api.add_resource(HelloWorld, '/ws/pt2/')
if __name__ == '__main__':
app.run(debug=True, host='0.0.0.0', port=443, ssl_context=('secret.pem', 'secret.key'))
flask
添加https
支持,只需要在app.run
中添加ssl_context
参数。
openssl req -new -x509 -days 365 -nodes -out secret.pem -keyout secret.key
openssl pkcs8 -topk8 -inform PEM -outform PEM -in secret.key -out outfile.pem
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。