1.安装ActivePython-2.7.2.5-win32-x86.msi
 
安装完成默认目录“C:\Python27”,系统环境变量PATH=“C:\Python27\;C:
 
\Python27\Scripts;%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;
 
%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\;C:\Program Files\Intel\WiFi\bin\;C:
 
\Program Files\Common Files\Intel\WirelessCommon\;E:\oracleLinux\instantclient_11_2
 
 
2.安装pip
 
C:\Python27\Scripts目录下easy_install,执行以下命令
 
C:\Users\Administrator>easy_install pip
Searching for pip
Best match: pip 1.0.1
Adding pip 1.0.1 to easy-install.pth file
Installing pip-script.py script to C:\Python27\Scripts
Installing pip.exe script to C:\Python27\Scripts
Installing pip-2.7-script.py script to C:\Python27\Scripts
Installing pip-2.7.exe script to C:\Python27\Scripts
 
Using c:\python27\lib\site-packages
Processing dependencies for pip
Finished processing dependencies for pip
 
C:\Users\Administrator>
 
3.安装Flask
 
C:\Users\Administrator>pip install Flask
Downloading/unpacking Flask
  Downloading Flask-0.9.tar.gz (481Kb): 481Kb downloaded
  Running setup.py egg_info for package Flask
 
    warning: no files found matching '*' under directory 'tests'
    warning: no previously-included files matching '*.pyc' found under directory
 'docs'
    warning: no previously-included files matching '*.pyo' found under directory
 'docs'
    warning: no previously-included files matching '*.pyc' found under directory
 'tests'
    warning: no previously-included files matching '*.pyo' found under directory
 'tests'
    warning: no previously-included files matching '*.pyc' found under directory
 'examples'
    warning: no previously-included files matching '*.pyo' found under directory
 'examples'
    no previously-included directories found matching 'docs\_build'
    no previously-included directories found matching 'docs\_themes\.git'
Downloading/unpacking Werkzeug>=0.7 (from Flask)
  Downloading Werkzeug-0.8.3.tar.gz (1.1Mb): 1.1Mb downloaded
  Running setup.py egg_info for package Werkzeug
 
    warning: no files found matching '*' under directory 'werkzeug\debug\templat
es'
    warning: no files found matching '*' under directory 'tests'
    warning: no previously-included files matching '*.pyc' found under directory
 'docs'
    warning: no previously-included files matching '*.pyo' found under directory
 'docs'
    warning: no previously-included files matching '*.pyc' found under directory
 'tests'
    warning: no previously-included files matching '*.pyo' found under directory
 'tests'
    warning: no previously-included files matching '*.pyc' found under directory
 'examples'
    warning: no previously-included files matching '*.pyo' found under directory
 'examples'
    no previously-included directories found matching 'docs\_build'
Downloading/unpacking Jinja2>=2.4 (from Flask)
  Downloading Jinja2-2.6.tar.gz (389Kb): 389Kb downloaded
  Running setup.py egg_info for package Jinja2
 
    warning: no previously-included files matching '*' found under directory 'do
cs\_build'
    warning: no previously-included files matching '*.pyc' found under directory
 'jinja2'
    warning: no previously-included files matching '*.pyc' found under directory
 'docs'
    warning: no previously-included files matching '*.pyo' found under directory
 'jinja2'
    warning: no previously-included files matching '*.pyo' found under directory
 'docs'
Installing collected packages: Flask, Werkzeug, Jinja2
  Running setup.py install for Flask
 
    warning: no files found matching '*' under directory 'tests'
    warning: no previously-included files matching '*.pyc' found under directory
 'docs'
    warning: no previously-included files matching '*.pyo' found under directory
 'docs'
    warning: no previously-included files matching '*.pyc' found under directory
 'tests'
    warning: no previously-included files matching '*.pyo' found under directory
 'tests'
    warning: no previously-included files matching '*.pyc' found under directory
 'examples'
    warning: no previously-included files matching '*.pyo' found under directory
 'examples'
    no previously-included directories found matching 'docs\_build'
    no previously-included directories found matching 'docs\_themes\.git'
  Running setup.py install for Werkzeug
 
    warning: no files found matching '*' under directory 'werkzeug\debug\templat
es'
    warning: no files found matching '*' under directory 'tests'
    warning: no previously-included files matching '*.pyc' found under directory
 'docs'
    warning: no previously-included files matching '*.pyo' found under directory
 'docs'
    warning: no previously-included files matching '*.pyc' found under directory
 'tests'
    warning: no previously-included files matching '*.pyo' found under directory
 'tests'
    warning: no previously-included files matching '*.pyc' found under directory
 'examples'
    warning: no previously-included files matching '*.pyo' found under directory
 'examples'
    no previously-included directories found matching 'docs\_build'
  Running setup.py install for Jinja2
 
    warning: no previously-included files matching '*' found under directory 'do
cs\_build'
    warning: no previously-included files matching '*.pyc' found under directory
 'jinja2'
    warning: no previously-included files matching '*.pyc' found under directory
 'docs'
    warning: no previously-included files matching '*.pyo' found under directory
 'jinja2'
    warning: no previously-included files matching '*.pyo' found under directory
 'docs'
Successfully installed Flask Werkzeug Jinja2
Cleaning up...
 
C:\Users\Administrator>
 
4. 配置应用目录
 
C:\Users\Administrator>e:
E:\>cd python
E:\python>cd web
E:\python\web>virtualenv venv
New python executable in venv\Scripts\python2.7.exe
Not overwriting existing python script venv\Scripts\python.exe (you must use ven
v\Scripts\python2.7.exe)
Installing distribute...........................................................
................................................................................
...............................................done.
Installing pip..............done.
 
E:\python\web>
 
5.激活virtualenv 中的 Flask:
 
E:\python\web>venv\Scripts\activate.bat
(venv) E:\python\web>pip install Flask
Requirement already satisfied (use --upgrade to upgrade): Flask in c:\python27\l
ib\site-packages
Requirement already satisfied (use --upgrade to upgrade): Werkzeug>=0.7 in c:\py
thon27\lib\site-packages (from Flask)
Requirement already satisfied (use --upgrade to upgrade): Jinja2>=2.4 in c:\pyth
on27\lib\site-packages (from Flask)
Cleaning up...
 
(venv) E:\python\web>exit
 
6.进入E:\python\web目录编写app测试文件
 
from flask import Flask
app = Flask(__name__)
 
@app.route('/')
def hello_world():
    return 'Hello World!'
 
if __name__ == '__main__':
    app.run()
 
7.运行脚本
 
Microsoft Windows [版本 6.1.7601]
版权所有 (c) 2009 Microsoft Corporation。保留所有权利。
 
C:\Users\Administrator>e:
 
E:\>cd python
 
E:\python>cd web
 
E:\python\web>python hello.py
 * Running on http://127.0.0.1:5000/
 
8.浏览器地址输入“http://127.0.0.1:5000”
 
浏览器窗口输出“Hello World!”