Flask大型教程项目
2018-03-21 本文已影响0人
王象
链接地址:
http://www.pythondoc.com/flask-mega-tutorial/helloworld.html
安装环境:
系统环境:ubuntu16.04+python3(3.5)
mkdir microblog
cd microblog
安装sudo apt-get install python-virtualenv
python3 -m venv flask(创建python 3的虚拟环境)
cd flask
cd bin
(若提示未安装pip则安装即可,pip3,pip都安装了)
./pip install flask(这里务必注意使用创建flask环境中pip安装)
简单测试环境安装结果:
mkdir ~/microblog/app/
cd app
vim init.py
from flask import Flask
app = Flask(name)
from app import views
vim views.py
from app import app
@app.route('/')
@app.route('/index')
def index():
return "Hello, World!"
cd ~/microblog
vim run.py
!flask/bin/python
from app import app
app.run(debug = True)
chmod a+x run.py
出现一下内容,代表成功
- Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)
- Restarting with stat
- Debugger is active!
- Debugger PIN: 313-322-908