Skip to content

linkedbyte/python-https-servers

 
 

Repository files navigation

Python https servers

Examples of an https server for development. Never use them for production.

Samples

There're 3 samples.

  1. Python standard libraries
  2. Gunicorn
  3. Gunicorn + Flask

Usage

Preparation

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'
-----

1. Python standard libraries

Just execute run-python.sh.

./run-python.sh

2. Gunicorn

Install the required packages with Poetry or pip.

poetry install
# or
python3 -m pip install gunicorn

Then execute run-gunicorn.sh.

./run-gunicorn.sh

3. Gunicorn + Flask

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

Files

├── 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

Reference

About

Examples of an https server for development. They work on Python 3.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 79.7%
  • HTML 7.9%
  • Shell 6.5%
  • CSS 5.9%