flask 学习

Posted hanzhang

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了flask 学习相关的知识,希望对你有一定的参考价值。

最近学习flask框架,是照着图灵丛书《Flask Web开发》来学的。

照着第2章写了个简单的框架

#_*_coding:utf-8 _*_
from flask import Flask
app = Flask(__name__)

@app.route(\'/\')
def index():
    return \'<h1>hello</h1>\'

@app.route(\'/hello\')
def hello():
    return \'<h2>hello,there</h2>\'

@app.route(\'/user/<name>\')
def user(name):
    return \'<h2>hello,%s!<h2>\' %name    
    

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

在自己电脑布置了virtualenv环境,通过它运行了程序

需要提一下,在首行加了  #_*_coding:utf-8 _*_    

文本才可以写中文,不然无法识别。

后面接着学习。

 

以上是关于flask 学习的主要内容,如果未能解决你的问题,请参考以下文章