码迷,mamicode.com
首页 > 其他好文 > 详细

开始Flask项目

时间:2017-11-03 17:37:00      阅读:136      评论:0      收藏:0      [点我收藏+]

标签:url   程序   logs   ext   设置   reg   height   register   首页   

新建Flask项目。

设置调试模式。

理解Flask项目主程序。

使用装饰器,设置路径与函数之间的关系。

使用Flask中render_template,用不同的路径,返回首页、登录员、注册页。

用视图函数反转得到URL,url_for(‘login’),完成导航里的链接。

from flask import Flask,render_template

app = Flask(__name__)

@app.route(‘/‘)
def index():
    return render_template(‘index.html‘)


@app.route(‘/login/‘)
def login():
    return render_template(‘login.html‘)


@app.route(‘/register/‘)
def register():
    return render_template(‘register.html‘)

if __name__ == ‘__main__‘:
    app.run(debug=True)

技术分享

 

开始Flask项目

标签:url   程序   logs   ext   设置   reg   height   register   首页   

原文地址:http://www.cnblogs.com/cyj5201314/p/7779229.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!