一、Pipenv管理项目

Pipenv使用

# python3 --version   ---> Python 3.7.0
pip3 install pipenv

Pipenv管理虚拟环境

mkdir myproject && cd myproject
pipenv --python 3.7
pipenv shell

Pipenv安装Flask

(myproject) [root@localhost myproject]#  pipenv install flask

测试小Web程序

(myproject) [root@localhost myproject]# cat app.py

from flask import Flask
app = Flask(__name__)

app.debug = True

@app.route('/')
def index():
  return '<h1>Hello World!</h1>'

if __name__ == '__main__':
  app.run()

# 默认端口5000, 指定地址,端口: app.run(host='0.0.0.0',port=8080)
(myproject) [root@localhost myproject]# python app.py
[root@localhost ~]# curl 127.0.0.1:5000 
<h1>Hello World!</h1>

Last updated