from flask import Flask, render_template, url_for, request
app = Flask(__name__,template_folder='templates',static_url_path='/static', static_folder='/static')
# 模板文件夾 映射到web中的訪問路徑 項目中的目錄名稱
@app.route('/requests')
def index():
headers = request.headers
# referer = request.headers['referer']
scheme = request.scheme
method = request.method
args = request.args
form = request.form
values = request.values
cookies = request.cookies
path = request.path
full_path = request.full_path
files = request.files
url = request.url
return render_template('03_requests.html',params=locals())
@app.route('/')
def temp():
dic = {
'title': '我的模板',
'bookName': '人與永恒',
'price': '35.5',
'author': '周國平'
}
uname = "lux"
title = '我的模板'
bookName = '人與永恒'
price = '35.5'
author = '周國平'
string = 'hei , this is a jotting.'
list = ['A', 'B', 'C', 'D']
tup = ('a', 'b', 'c', 'd')
# print(locals()) # 局部變量組成的字典
return render_template('01_temp.html', parameter=locals())
# return "Welcome!"
@app.route("/login")
def login():
return render_template('login.html')
# 404頁面
@app.errorhandler(404)
def page_not_found(e):
return render_template('404.html'), 404
if __name__ == '__main__':
app.run(debug=True, port=5556)
app.py文件
最后編輯于 :
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。