• Stars
    star
    650
  • Rank 69,267 (Top 2 %)
  • Language
    Python
  • Created about 13 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

An empty project skeleton / boilerplate for flask projects. Powered by CookieCutter.

Flask Empty

version 0.6.5

Flask-Empty is a simple flask boilerplate for fast prototyping. Just use cookiecutter and create a new project in no time.

# if cookiecutter is not installed
pip3 install cookiecutter

# using cookiecutter // linux/Mac
cookiecutter https://github.com/italomaia/flask-empty

# answer the prompt and you're done!

Getting Started

You're advised to use venv from here on. In your project folder, create and enable it like this:

python3 -m venv venv
. venv/bin/activate  # [.csh|.fish]

# install required packages
pip3 install -r requirements.txt

# loads env variables and runs the project in development mode
make run-dev

Getting Started With Docker

Given you have up-to-date docker installed in your machine, all you need to do is:

# build container image
docker build . -t my-project-name
# run container in development mode
docker run --rm -p 5000:5000 my-project-name

Environment Variables

For flask to run correctly, some environment variables need to be set. The ones needed by your project can be seen in the Dockerfile or Makefile files. For a list of all other optional environment variables, check this link. When using docker, you can easely set them inline before each run. When using docker-compose, set them in the yaml configuration file for each environment.

Important files to be aware of

/extensions.py all extension instances that need initialization should be available here, so Empty can see and initialize them for you. If instantiated somewhere else, just import them here and you should be fine.

/config.py has pre-set configuration classes for you to meddle with. They're are all self explanatory and commented.

/main.py instantiates your project's main class. Override it to quickly add custom extension setups, simple views, context processors, etc. It already has some sensitive defaults for most use cases. See https://github.com/italomaia/empty for the available options.

<project>/<project>.ini is the configuration file used with uwsgi. Use it like this:

uwsgi --ini your_project.ini

commands.py adds few very useful commandline commands (...) to help your development productivity. You can also add your own. Check available commands by running FLASK_ENV=development FLASK_CONFIG_DEFAULT=Dev flask in the terminal.

Heroku

Empty comes with a pre-configured procfile and heroku() wrapper for app_factory. No setup required.

Other topics

Templates

There are some error templates bundled with flask-empty by default. All empty right now. Just fill them up for your project.

Macros

You can use the jinja2 macros available in templates/macros to easily integrate your jinja2 templates with flask extensions like wtforms and common tasks like showing flash messages.

Available macros, formhelpers and flashing are very useful.

Blueprints

You can create blueprints easily with make new-app. The will live, by default at apps folder. Remember to configure your blueprints in config.py so that they can be properly loaded.

Json Friendly

Variables true, false and null are now supported as aliases for True, False and None. This way, valid json can be copy-pasted directly into your code and will be interpreted as valid python. Ex: data = {"x": true, "y": false, "z": null}

Supported Extensions

Flask-SQLAlchemy

While creating your project, Flask-Empty will ask you if you wish to enable SQL support. Confirm if you do so and Flask-SQLAlchemy will be made available. See config.py for its default configuration.

_ps: currently, db-create will only create your models if they are imported somewhere in your application.

By somewhere, try the same module where your Blueprint instance is defined.

Flask-Mongoengine

As mongodb is really cool, supporting it is a must. Just say yes at the prompt when asked and Flask-Mongoengine will be setup for you.

Flask-WTF

Flask-WTF is the "the facto" extension for handling forms with Flask. It is simply great, and Flask-Empty supports it! Just say "yes" during project creation and Flask-WTF support will be on.

Flask-Admin

Just create an admin.py file in your blueprint, define your admin models inside and change LOAD_MODULES_EXTENSIONS to also pre-load admin, like this:

Flask-Marshmallow

Gives you, almost for free, model serialization, deserialization and validation. Also quite handy for fast development of rest applications.

Flask-Security

Get user session and permissioning out-of-the-box with this great project.

Examples

The blog example in this project is probably outdated by now, so, just create a new project and mess around to your heart's content for quick learning.

FAQ

Is flask-empty boilerplate compatible with flask 0.x? Cuz' that's what my app uses.

Right now, flask-empty is a very simple project where many good practices and code examples were glued together.

Until recently I was focused in keeping backward compatibility with flask 0.8. Well, that goal is no more.

Flask-empty will be compatible with the latest version of Flask and, by chance, with previous versions. Things will be easier (for me!) this way.

So, which is the oldest version where flask-empty works?

In my last test, version 1.0.

I think flask-empty should have this and that configured by default. Will you add support?

My current goals are:

  • Make flask-empty real easy to start a project with
  • Keep things simple and robust

If your suggestion is simple, VERY useful and has little overhead, I'll probably consider adding it to the project.

If you make the code and send a pull request, then I'll consider it real hard. Now, if your suggestion is rejected or advised in a different approach, don't get sad (you're awesome ;).

I just made a cool example with flask-empty and want to add it to examples.

Pull request it for evaluation ;) Just keep in mind that good examples are short (not really...) and focused in it's showcase.

More Repositories

1

vuejs-python

Examples showing how to use vuejs with python web frameworks (rest, websocket, etc)
Python
133
star
2

read-lua-source-code

Articles, links and suggestion on how to read the lua programming language source code.
75
star
3

flask-vue-semantic-docker

Flask+VueJS+SemanticUI+Nginx+Docker boilerplate. Also, see https://pypi.python.org/pypi/fvsd
Python
40
star
4

mdx-video

Video extension for python-markdown
Python
17
star
5

flask-empty-api

AZAP Flask boilerplate for creating API's with flask.
Python
14
star
6

mangarock.py

(deprecated) mangarock script to download comics
Python
13
star
7

lua_table

Set of useful lua functions for manipulating tables.
Lua
11
star
8

django-comics

Django app for webcomics
Python
11
star
9

uri-faker

See how fonts can be used to create fake URIs
HTML
7
star
10

mangafox

Python
5
star
11

to-cbz

Command line tool to create packed comic files
Python
4
star
12

luabatteries

Lua
4
star
13

flask-rev

Allows you to keep an aggressive cache policy with your HTTP server while using flask.
Python
4
star
14

helix-non-modal-config

The helix config I use for my helix editor
Python
4
star
15

pugce

Python Users Group Cearรก
Python
4
star
16

data-factory

Data factory implementation for python.
Python
3
star
17

lua_fun

Functional programming library for lua lang.
Lua
3
star
18

flask-empty-compose

Flask-Empty based boilerplate with docker-compose. Let's make deployment easy ; )
Dockerfile
3
star
19

empty

Sometimes, starting your flask project takes too much work. Well, empty leverages that for you.
Python
2
star
20

fabric-compose

Fabric recipe for running a simple docker-compose project in any language
Dockerfile
2
star
21

gulp-starter-vue

CoffeeScript
2
star
22

podman-axum-example

Example setup with podman+axum
Python
2
star
23

mymaps

MyMap
JavaScript
1
star
24

renamer

Command line pyrenamer-like tool
Python
1
star
25

manga-scrap

Python
1
star
26

blog

JavaScript
1
star
27

gae_installer

This script makes it easy to install app_engine in your linux distro
Python
1
star
28

gae

Layer framework for googleapp engine.
Python
1
star
29

docker-truffle

Docker truffle playground. See also https://github.com/italomaia/docker-truffle-miner
Shell
1
star
30

Touchpad-Script

Script to enable or disable touchpad for linux. Great for netbooks!
Shell
1
star
31

docker-truffle-miner

Create a private ethereum blockchain with docker. For studying.
Shell
1
star
32

fvsd-cli

Flask+VueJS+SemanticUI+Nginx+Docker boilerplate creator. Also, see https://github.com/italomaia/flask-vue-semantic-docker
Python
1
star
33

luajit-almanac

Humble attempt into putting together info about the current state of luajit and a bit of its history
1
star