例子如下:
from flask import Flask
app = Flask (__name__)
@app.route('/client/<path:path>')
def send_static(path):
""" serves all files from ./client/ to ``/client/<path:path>``
:param path: path from api call
"""
print("path=",path)
return "hello World"
if __name__ == '__main__':
app.run(debug=True)
運行:
python test.py
瀏覽器訪問:
http://127.0.0.1:5000/client/test
終端會輸出:
path= test