Create flask API's in minutes, ๐น watch the video tutorial.
- Extensive documentation here.
- Integrated with Pipenv for package managing.
- Fast deloyment to heroku with
$ pipenv run deploy
. - Use of
.env
file. - SQLAlchemy integration for database abstraction.
This template installs itself in a few seconds if you open it for free with Codespaces (recommended) or Gitpod. Skip this installation steps and jump to step 2 if you decide to use any of those services.
Important: The boiplerplate is made for python 3.10 but you can easily change the
python_version
on the Pipfile.
The following steps are automatically runned withing gitpod, if you are doing a local installation you have to do them manually:
pipenv install;
psql -U root -c 'CREATE DATABASE example;'
pipenv run init;
pipenv run migrate;
pipenv run upgrade;
There is an example API working with an example database. All your application code should be written inside the ./src/
folder.
- src/main.py (it's where your endpoints should be coded)
- src/models.py (your database tables and serialization logic)
- src/utils.py (some reusable classes and functions)
- src/admin.py (add your models to the admin and manage your data easily)
For a more detailed explanation, look for the tutorial inside the docs
folder.
You have to migrate and upgrade the migrations for every update you make to your models:
$ pipenv run migrate # (to make the migrations)
$ pipenv run upgrade # (to update your databse with the migrations)
This boilerplate it's 100% read to deploy with Render.com and Herkou in a matter of minutes. Please read the official documentation about it.
This template was built as part of the 4Geeks Academy Coding Bootcamp by Alejandro Sanchez and many other contributors. Find out more about our Full Stack Developer Course, and Data Science Bootcamp.
You can find other templates and resources like this at the school github page.
You can change the location of your SQLite database by updating the SQLALCHEMY_DATABASE_URI configuration in your Flask application. Right now, it's set to "sqlite:////tmp/test.db" which is placing the database in your system's temporary files directory.
To move the SQLite database file to a more permanent location, you can change this to something like the following:
python Copy code app.config['SQLALCHEMY_DATABASE_URI'] = "sqlite:////path/to/your/database.db" Just replace "/path/to/your/" with the actual path where you want the SQLite database file to be stored.
Remember to create the directory if it doesn't exist, and ensure that your application has the necessary read/write permissions to access the directory and create files there. If you're running this on a Unix-like system, you can use the mkdir command to create the directory, and chown or chmod to adjust the permissions.
Also, please note that SQLite is great for development and testing, but for production environments, a more robust system like PostgreSQL or MySQL is recommended.