Examples of an https server for development. Never use them for production.
There're 3 samples.
- Python standard libraries
- Gunicorn
- Gunicorn + Flask
Generate a self-signed certificate and name it localhost.pem
.
cd python-https-servers/
openssl req -x509 -new -days 365 -nodes \
-keyout localhost.pem \
-out localhost.pem \
-subj "/CN=localhost"
Generating a 2048 bit RSA private key
.....................................................................................................................................+++
........+++
writing new private key to 'localhost.pem'
-----
Just execute run-python.sh
.
./run-python.sh
Install the required packages with Poetry or pip
.
poetry install
# or
python3 -m pip install gunicorn
Then execute run-gunicorn.sh
.
./run-gunicorn.sh
Install the required packages with Poetry or pip
.
poetry install
# or
python3 -m pip install gunicorn Flask
Then execute run-gunicorn-flask.sh
.
./run-gunicorn-flask.sh
You can view the sample html file on your browser with https://localhost
.
open https://localhost
├── README.md: This file
├── gunicorn.conf.py: Config file for Gunicorn
├── htdocs: Served directory
├── localhost.pem: Self-signed certificate (You need to create this.)
├── poetry.lock: Poetry lock file (You don't need this if you don't use Poetry)
├── pyproject.toml: Poetry project file (You don't need this if you don't use Poetry)
├── run-gunicorn-flask.sh: Script to run `with_gunicorn_flask/app.py`
├── run-gunicorn.sh: Script to run `with_gunicorn/app.py`
├── run-python.sh: Script to run `with_python/server.py`
├── with_gunicorn
│ └── app.py: Sample with Gunicorn
├── with_gunicorn_flask
│ └── app.py: Sample with Gunicorn and Flask
└── with_python
└── server.py: Sample with Python standard libraries