windows环境+pycharm+python3
1、命令提示窗口
1)创建项目目录:mkdir myblog
2)cd myblog
3)创建虚拟环境:python -m venv myvenv
4)激活虚拟环境:venvScriptsactivate
5)安装flask:pip install flask
6)创建应用:mkdir myapp
2、pycharm开发工具中:
1)myapp目录下新建__init__.py:
from flask import Flask
app = Flask(__name__)
from myapp import routes
2)app目录下新建routes.py:
from myapp import app
@app.route('/')
@app.route('/index')
def index():
return "Hello"
3)myblog目录下新建myblog.py:
from myapp import app
3、命令提示窗口
1)myblog路径下,设置FLASK_APP环境变量:set FLASK_APP=myblog.py
2)启动服务:flask run