Flask删除响应头的Server信息

关键代码:

Copy
from flask import Flask, make_response
from werkzeug.serving import WSGIRequestHandler

app = Flask(__name__)

@app.before_request
def set_server_header():
WSGIRequestHandler.server_version = ''
WSGIRequestHandler.sys_version = ''

@app.route('/')
def index():
return 'Hello, World!'

if __name__ == '__main__':
app.run()