pipenv install flask pipenv run python3 hello_world.py
結果如下
1 2 3 4 5
* Serving Flask app 'hello_world' * Debug mode: off WARNING: This is a development server. Do not use it in a production deployment. Use a production WSGI server instead. * Running on http://127.0.0.1:5000 Press CTRL+C to quit
使用Gunicorn
安裝gunicorn
1 2
pipenv install gunicorn pipenv run gunicorn hello_world:app
==> nginx: stable 1.23.2 (bottled), HEAD HTTP(S) server and reverse proxy, and IMAP/POP3 proxy server https://nginx.org/ /usr/local/Cellar/nginx/1.23.2 (26 files, 2.2MB) * Poured from bottle on 2022-11-09 at 20:34:30 From: https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/nginx.rb License: BSD-2-Clause ==> Dependencies Required: openssl@1.1 ✔, pcre2 ✔ ==> Options --HEAD Install HEAD version ==> Caveats Docroot is: /usr/local/var/www
The default port has been set in /usr/local/etc/nginx/nginx.conf to 8080 so that nginx can run without sudo.
nginx will load all files in /usr/local/etc/nginx/servers/.
To restart nginx after an upgrade: brew services restart nginx Or, if you don't want/need a background service you can just run: /usr/local/opt/nginx/bin/nginx -g daemon off; ==> Analytics install: 49,084 (30 days), 114,716 (90 days), 459,040 (365 days) install-on-request: 49,004 (30 days), 114,535 (90 days), 458,238 (365 days) build-error: 0 (30 days)