"path:path"在路由中的使用

例子如下:

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

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章