Skip to content

Quick Start

Hey maker, welcome to PythonStarter (Flask edition) 👋

This section includes first quick and easy steps to get the basics of this project up-and-running on your local machine.

Once you are done with this part, I will show you how to do a full database setup and quickly deploy to the Render cloud service so you will have this code launched at a live url (for free)!

Before you begin with the steps below, I highly recommend that you install the Pyenv Python version manager. See my instructions for Mac users here and for Windows users here.

IMPORTANT: To avoid any errors, its important to follow all these steps in order. So I strongly advise you not to skip anything here!

After you download and unzip the codebase, complete following steps:

1. Create and activate your virtual environment with the name ".venv":

This will create your project-specific local Python installation in the .venv hidden folder. Run these commands in your project directory:

First, create the virtual environment:

python -m venv .venv

Then activate it:

source .venv/bin/activate

2. Install the Python packages in requirements.txt:

pip install -r requirements.txt

3. Install and build the frontend npm packages for Tailwind CSS and DaisyUI

(Don't worry this is only for CSS styling, there are no complex JavaScript dependencies here)

First install the packages:

npm install

Then build it to generate all the CSS

npm run build

After this use the watch command to automatically monitor and add styling changes:

npm run watch

Note: the instructions for these commands are defined in: package.json

4. Generate a secure keys for your database env values.

(Run the command below once for the SECRET_KEY and once for SECURITY_PASSWORD_SALT, then add the values in the .env file below)

python -c "import secrets; print(secrets.token_hex(32))"

5. Create an .env file in the project root:

(This is ok to be mainly blank for now, but we need some temporary placeholders for the AWS variables and for RENDER_DB_URL so the project will run)

SECRET_KEY=[INSERT YOUR GENERATED SECRET KEY HERE]
SECURITY_PASSWORD_SALT=[INSERT YOUR GENERATED SECURITY_PASSWORD_SALT]
RENDER_DB_URL=sqlite:///local_dev_placeholder.db

DEV_STRIPE_PUBLISHABLE_KEY=
DEV_STRIPE_SECRET_KEY=
DEV_STRIPE_ONE_OFF_PRICE_ID=
STRIPE_WEBHOOK_SECRET=

AWS_REGION=eu-west-2
AWS_ACCESS_KEY_ID=placeholder
AWS_SECRET_ACCESS_KEY=placeholder
AWS_S3_BUCKET=placeholder-bucket

SLACK_BOT_USER_TOKEN=

6. Initialise the database

The project uses Flask-Migrate (Alembic) to manage the database schema. Run the existing migrations against your PostgreSQL database:

flask db upgrade

This creates all required tables: user, role, product, product_access, and the Flask-Security supporting tables.

If you need to verify the migration succeeded, you can check the current revision:

flask db current

7. Run the Flask app

flask run -p 5001

8. For CSS changes, run the npm watcher in a separate terminal:

npm run watch

Open http://localhost:5001.