Coder Social home page Coder Social logo

dystudio / flask-boost Goto Github PK

View Code? Open in Web Editor NEW

This project forked from hustlzp/flask-boost

0.0 1.0 0.0 2.66 MB

Flask application generator for boosting your development.

License: MIT License

Python 64.92% JavaScript 14.02% HTML 16.77% CSS 3.54% Shell 0.04% Mako 0.71%

flask-boost's Introduction

Flask-Boost

Latest Version Downloads Per Month Python Versions The MIT License

Flask application generator for boosting your development.

Features

  • Well Defined Project Structure
    • Use factory pattern to generate Flask app.
    • Use Blueprints to organize controllers.
    • Split controllers, models, forms, utilities, assets, Jinja2 pages, Jinja2 macros into different directories.
    • Organize Jinja2 page assets (HTML, JavaScript, CSS) to the same directory.
    • Organize Jinja2 macro assets (HTML, JavaScript, CSS) to the same directory.
  • Batteries Included
    • Use Flask-SQLAlchemy and Flask-Migrate as database tools.
    • Use Flask-WTF to validate forms.
    • Use Flask-Script to help writing scripts.
    • Use permission to define permissions.
    • Use Bootstrap as frontend framework.
    • Use Bower to manage frontend packages.
    • Use Gulp and FIS to compile static assets.
    • Use Gunicorn to run Flask app and Supervisor to manage Gunicorn processes.
    • Use Fabric as deployment tool.
    • Use Sentry to log exceptions.
    • Use Nginx to serve static files.
  • Scaffold Commands
    • Generate project files: boost new <project>
    • Generate controller files: boost new controller <controller>
    • Generate action files: boost new action <controller> <action> [-t]
    • Generate form files: boost new form <form>
    • Generate model files: boost new model <model>
    • Generate macro files: boost new macro <category> <macro> or boost new macro <macro>

Installation

pip install flask-boost

Development Guide

Init project

boost new <your_project_name>

Setup backend requirements

cd <your_project_dir>
virtualenv venv
. venv/bin/activate (venv\Scripts\activate in Windows)
pip install -r requirements.txt

Note: if you failed in pip install -r requirements.txt in Windows, try to install package binaries directly:

Init database

Create database with name your_project_name and encoding utf8.

Update SQLALCHEMY_DATABASE_URI in config/development.py as needed.

Then init tables:

python manage.py db upgrade

Run app

Run local server:

python manage.py run

Setup frontend requirements

Install Node.js first and then install Bower, FIS and Gulp globally:

npm install -g bower
npm install -g fis
npm install -g fis-postpackager-simple
npm install -g gulp

Install local packages:

npm install
bower install

Run Gulp watch task

gulp watch

LiveReload support

Install LiveReload browser extension from here.

And use python manage.py live instead of python manage.py run to start app.

Scaffold commands

boost new <project>
boost new controller <controller>
boost new action <controller> <action> [-t]
boost new form <form>
boost new model <model>
boost new macro <category> <macro>
boost new macro <macro>
boost -v
boost -h

Recommended IDE

PyCharm is the recommended IDE for Flask-Boost.

Recommended preferences:

  • In Preferences -> Project -> Project Interpreter, set venv as project interpreter.
  • In Preferences -> Project -> Project Structure, set application/pages and application/macros as template folders, set application and application/static/css as resource folders.
  • In Language & Frameworks -> JavaScript -> Bower, set bower.json as bower.json.

Recommended PyCharm plugins:

  • .ignore
  • Markdown
  • Bootstrap3

First Production Deploy

Config server

Install mysql-server, python-virtualenv, git, supervisor, nginx, g++, python-dev, libmysqlclient-dev, libxml2-dev, libxslt-dev on your server.

Install requirements

git clone **.git
cd <your_project_dir>
virtualenv venv
. venv/bin/activate
pip install -r requirements.txt

Config app

Save config/production_sample.py as config/production.py, update configs in config/production.py as needed and transfer it to server.

Note: remember to update SECRET_KEY in config/production.py! You can generate random secret key as follows:

>>> import os
>>> os.urandom(24)

Init database

Create database with name your_project_name and encoding utf8.

And run:

export MODE=PRODUCTION
python manage.py db upgrade

Copy config files

Update project root path as needed in deploy/nginx.conf and deploy/supervisor.conf.

cp deploy/flask_env.sh /etc/profile.d/
cp deploy/nginx.conf /etc/nginx/conf.d/<your_project_name>.conf
cp deploy/supervisor.conf /etc/supervisor/conf.d/<your_project_name>.conf

Build assets

Install Node.js first and then install Bower, FIS and Gulp globally:

npm install -g bower
npm install -g fis
npm install -g fis-postpackager-simple
npm install -g gulp

Install local packages:

npm install
bower install

Then:

gulp
python manage.py build

Start app

service nginx restart
service supervisor restart

Daily Production Deploy

Update HOST_STRING in config with the format user@ip.

Commit your codes and run:

git push && fab deploy

P.S. If you wanna to deploy flask with Apache2, see this post.

License

MIT

flask-boost's People

Contributors

daimon99 avatar hustlzp avatar royopa avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.