Please note: After iterating on this project for a while, I ended up building out a more generic variant that allows you to build your desired Python server in a more a la carte fashion. I recommend using it instead (particularly if you need a server that does not use a database, needs an async database API with FastAPI, or similar): https://github.com/onecrayon/cookiecutter-musketeers-python
This is a Cookiecutter template that bootstraps a "3 Pythoneers" project using either FastAPI or Falcon 3 (WSGI or ASGI).
Please note: Falcon 3 is currently a pre-release! I am including it because the
WSGI functionality is quite stable (mostly unchanged from Falcon 2). If you use ASGI under
Falcon 3, you will additionally be using the SQLAlchemy 1.4 pre-release and
asyncpg
instead of psycopg2
. Async SQLAlchemy requires using SQLAlchemy 2.0 style
queries! Please see the SQLAlchemy Changelog
for more details.
Python APIs are really annoying to develop locally, because you have to install a database, make sure you've got the right version of Python (which could be different across different projects), plus a number of other headaches.
A 3 Musketeers project requires you to populate a .env
file,
and run a single command. And it works exactly the same on macOS, Windows, and Linux.
You'll never look back.
I do not recommend using this template with a globally-installed version of Cookiecutter
because the post-run script: 1) requires sh
in a Unix environment; and 2) will install Poetry
in your global default Python namespace, which you probably don't want.
Instead, you should get a head-start on your 3 Musketeers local environment by installing the following:
- Docker
- Docker Compose (included in Docker Desktop on Windows and macOS)
- Make
After installing the dependencies above, simply run make
from the root directory! Once the
Docker container is built, you will be able to proceed through the standard Cookiecutter command
line interface to create your project. You can then move your newly created project folder
out of this project's root directory, and you'll be good to go!
Refer to the README in your new project for how to get a local server up and running (you're halfway there already!).
Please note: in order to run Docker Desktop on Windows you will either need a recent copy of Windows 10 Home with WSL 2 enabled, or Windows 10 Pro.
One easy way to install make
on Windows:
- Install the Chocolatey package manager
- Run
choco install make
in an elevated command prompt