flask01 安装及初涉

.安装

1.pip的安装

$ curl -O https://raw.github.com/pypa/pip/master/contrib/get-pip.py

$ python get-pip.py

 

2.flask全局安装

$ sudo pip install Flask

  

 

二.第一个程序

 

root@alexknight:/mnt# mkdir microblog
root@alexknight:/mnt/microblog# mkdir  app
root@alexknight:/mnt/microblog# vim app/__init__.py

 

from flask import Flask

app=Flask(__name__)

from app import views
root@alexknight:/mnt/microblog# vim app/views.py

 

from app import app
@app.route(
'/') @app.route('/index') def index(): return "Hello, World!"

 

root@alexknight:/mnt/microblog# vim run.py

 

#!flask/bin/python

from app import app

app.debug=True

app.run()

 

结构目录如下:

 

运行结果:

 

posted @ 2014-07-08 13:56  李雷雷alexkn  阅读(331)  评论(2编辑  收藏  举报