> For the complete documentation index, see [llms.txt](https://close.gitbook.io/yun-wei-bi-ji/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://close.gitbook.io/yun-wei-bi-ji/python/flask/yi-pipenv-guan-li-xiang-mu.md).

# 一、Pipenv管理项目

## Pipenv使用

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

### Pipenv管理虚拟环境

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

### Pipenv安装Flask

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

### 测试小Web程序

```python
(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>
```
