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文件
最后编辑于 :
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。