- Major Changes since version 1
- What's included
- Requirements
- Instructions
- Other Resources
- Support My Work
Now updated to Flask 2.0.1
Flask Assets (along with cssmin and jsmin) are no longer used. These bundlers are quite out of date and have managed to break scripts. I've chosen to replace them with a webpack toolchain for bundling/minification. You may use it, abuse it or lose it. It's up to you.
If you prefer the old configuration, it still works! The dependencies are even up-to-date. You can find the old config on the v1 branch
Bootstrap Version
In this repo is flask web-app skeleton for a basic API or Flask powered website. Bootstrap 5 is included in the static/vendor folder and you may make whatever changes to static/js or static/css that you'd like. This repository comes pre-setup with Webpack to precompile SASSy styles and Typescript.
- Python (preferably Python3)
- Python Pip
- Pipenv for virtualenv & dependency management.
Optionally:
- NodeJS ^14.0 & NPM if you want to use the webpack config, or make your own config
- Clone this repository
git clone git@github.com:trev-dev/flask-starter.git
- Enter the flask-starter directory
cd flask-starter
- Install dependencies and setup virtualenv with
pipenv install
- Start a pipenv shell session with
pipenv shell
- Export your dev environment variables:
export FLASK_ENV=development export FLASK_APP=flaskr
- type
flask run
to start your dev server.
If you want to use the existing webpack config or make your own, all the usual steps to run npm need to happen. Once you have Node and NPM installed, run npm install
to install the dependencies. The scripts npm start
and npm run build
handle bundling for development and production respectively.
If you just want to write normal JS/CSS you can use the statics found at flaskr/static/
folder.
- Setup hosting for a domain and ensure you have passenger enabled for Python apps.
- Use FTP/SFTP/Git to move your project to its destination on Dreamhost (/home/username/example.com).
- Double check your Flask config at
flaskr/config.py
. It probably wouldn't hurt to make sure these are not commented out and set for production, especially the SECRET_KEY. - You may need a custom installation of Python3 on Dreamhost for this to work. Please see Dreamhost's Documentation on how to do this. The Pipfile for this repo calls for python 3.9. You may use 3.6 if you update the pipenv Pipfile.
- Once you've verified a usable Python3 installation, install
pipenv
on your Dreamhost server usingpip3 install pipenv
. - From the website root folder, run
pipenv install
to install the dependencies.- If you've installed a custom version of Python, pipenv can be pointed at it with
pipenv --python '/path/to/python/bin/python' install
. - If pipenv isn't on your PATH, you may use
python3 -m pipenv
instead
- If you've installed a custom version of Python, pipenv can be pointed at it with
- Wait a few minutes, then visit your website. It should be working. If not, Dreamhost has lots of documentation/support that can help you out. Enjoy!
The passenger_wsgi.py
is set up well enough that it might just work for you without further configuration.
If you get stuck it wouldn't hurt to check out:
- Flask's Documentation
- Dreamhost's Documentation on Python
- Brett's Beta - An amazing guide that I wish had been written before I tried to do this myself.