Skip to main content

A Flask project start-up CLI to create Flask modular ready projects.

Project description

flaskstarter 0.7

A Flask project start-up CLI to create modular ready projects.

Flaskstarter assumes you know about Flask microframework and its mechanics in a begginer level. It can be really helpful if you are still using monolithic aproach, and needs to start using a modular architecture.

It also assumes you are using Python 3.6+.

Flaskstarter recommends the use of a python virtual environment for project to work safely and isolated from your systems binnaries. You should create and activate it before the next steps.

To install flaskstarter use the usual:

pip install flaskstarter

To see its version:

flaskstarter --version

To see its help:

flaskstarter --help

To start a project, create its folder and:

flaskstarter init main_module_name

If you do want to use the same project's root folder as main module name:

flaskstarter init .

It won't create a requirements.txt on its own anymore, so you feel free to choose your tools.

To see init's help:

flaskstarter init --help

Now, after project creation, you can make full use of manage.py, a script with a CLI that may help you to automate some tasks inside project tree.

By now you can create a blueprint structure by typing the bellow on project root:

$ python manage.py plug-blueprint [blueprint_name]

If it will work as an API blueprint, that's enough. But maybe it is not and you want to use private templates related only to this blueprint. This is solved by adding a '-t' or '--templates' to the above command.

After that, flaskstarter goes onto main module > settings.toml file to register the blueprint on it. There is an EXTENSIONS variable where you can list all the plugins to autoimport if you create any by hand. It uses factory design.

For secrets settings, as secret_key and database configurations, refer to instance/.secrets.settings.toml

Most of the times you are adding some extensions and middlewares to your app, so you can add an empty skelleton to instanciate and plug to app by typing:

$ python manage.py plug-extension [name]

As with blueprints, flaskstarter registers extensions on main module > settings.toml.

To run your app you can use the bellow on project root:

$ python manage.py runserver

Ask manage.py for runserver help to see its options.

Now it is possible to plug a database and a migration extensions to the project. For a first experience Flaskstarter is running with flask-sqlalchemy and flask-migrate. The templates that generate the kickoff database use sqlite and the simplest thing possible. You will be able to plug a database by running:

$ python manage.py plug-database

When plug-database is ran, the manage script will create the migrations folder as Alembic requires. Once it is created the following commands will be available.

This will generate a migration script with Example as message:

$ python manage.py db-migrate Example

This upgrades the database:

$ python manage.py db-upgrade

If anything undesirable happens, this will downgrade the database:

$ python manage.py db-downgrade

For other Flask-Migrate commands, you can export FLASK_APP on your shell and use flask db (command) as its documentation guides.

What the project does for you

It creates project tree, the init and routes files with a helloworld example and a manage.py script to run the project and attach blueprints to it. The project settings are now on main module directory, so they can be persisted to a CVS repository.

A word of warning: when commiting and pushing your project to versioning servers, remember to put instance folder into .gitignore, if not yet. And then remember to place it into deploy destination.

What the project does not do for you

It doesn't force you to use poetry or any other tool but flask, toml and dynaconf on the Flask project created.

Future

  • Add automated tests for development enviroment of flaskstarter
  • Work on a better architecture for the generated project

How can you help on flaskstarter development?

Feel free to clone it and send us pull requests! Remember to comment the decisions you make so they can be better reviewed.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

flaskstarter-0.7.tar.gz (12.8 kB view details)

Uploaded Source

Built Distribution

flaskstarter-0.7-py3-none-any.whl (18.8 kB view details)

Uploaded Python 3

File details

Details for the file flaskstarter-0.7.tar.gz.

File metadata

  • Download URL: flaskstarter-0.7.tar.gz
  • Upload date:
  • Size: 12.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.13 CPython/3.10.1 Windows/10

File hashes

Hashes for flaskstarter-0.7.tar.gz
Algorithm Hash digest
SHA256 7c61d89d186e062375289190da55324312c0dfe5bc44103c36ef169c2fc17cba
MD5 a96e2d19edd64db4d525f3596b3e8b4f
BLAKE2b-256 b582e2b4601f6f26adc28a6a88566243ac29da7f2beb6696a648aa7f48efce0a

See more details on using hashes here.

File details

Details for the file flaskstarter-0.7-py3-none-any.whl.

File metadata

  • Download URL: flaskstarter-0.7-py3-none-any.whl
  • Upload date:
  • Size: 18.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.13 CPython/3.10.1 Windows/10

File hashes

Hashes for flaskstarter-0.7-py3-none-any.whl
Algorithm Hash digest
SHA256 3ed662210250bc85944207fe38f280644af69c00526ec3a2486951ed1c49d518
MD5 42bfaf9e126285b48c638579027d6fc1
BLAKE2b-256 ae996c1a3c2221b66a70315d064a8a942f0a5c96e1e42555a57c1c586a093739

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page