目录路径通过路由传入, 解析路由, 返回模板文件相应的地址
@app.route('/easyui/<docName>') #http://127.0.0.1:5000/easyui/jquery.easyui.min.js
def easyui(docName=None):
print("docName=",docName)
return render_template('jquery-easyui-1.7.0/'+docName) # / not \
@app.route('/easyui/<UrlName>/<docName>') # http://127.0.0.1:5000/easyui/themes/icon.css
def easyui2(UrlName=None,docName=None):
print("UrlName=",UrlName,"docName=",docName)
if docName.find(".css")>0:
return send_from_directory("templates", 'jquery-easyui-1.7.0/'+UrlName+"/"+docName)
return render_template('jquery-easyui-1.7.0/'+UrlName+"/"+docName) # / not \
# http://127.0.0.1:5000/easyui/themes/icons/edit_add.png
# http://127.0.0.1:5000/easyui/themes/default/easyui.css
@app.route('/easyui/<UrlName1>/<UrlName2>/<docName>') # http://127.0.0.1:5000/easyui/demo/datagrid/datagrid_data1.json
def easyui3(UrlName1=None,UrlName2=None,docName=None):
print("UrlName1=",UrlName1,"UrlName2=",UrlName2,"docName=",docName)
if docName.find(".png")>0:
return send_from_directory("templates", 'jquery-easyui-1.7.0/'+UrlName1+"/"+UrlName2+"/"+docName)
if docName.find(".css")>0:
return send_from_directory("templates", 'jquery-easyui-1.7.0/'+UrlName1+"/"+UrlName2+"/"+docName)