python3 + flask under ubuntu environment to build

1. Install pip

sudo apt-get install python3-dev
sudo apt install python3-pip

2. Install the tool virtualenv

sudo apt-get install python-virtualenv

3. Create a virtual environment using virtualenv tool, and active and the folder will appear in a folder venv

virtualenv -p /usr/bin/python3 py3env

. py3env/bin/activate

4. Installation flask pip

pip3 install flask

5. Create hello.py

Creating hello.py, as follows, located py3env folder
`from flask import Flask

app = Flask(name)

@app.route("/")
def hello():
return “hello world”

if name == “main”:
app.run()`

6 Use flask

export FLASK_APP=hello.py
export FLASK_ENV=development
flask run

Released seven original articles · won praise 0 · Views 275

Guess you like

Origin blog.csdn.net/weixin_42007220/article/details/103793738