Git Product home page Git Product logo

flask-scaffold's Introduction

Flask-Scaffold let's you scaffold a MySQL or PostgreSQL driven Web Application with Flask and Angularjs. It will create views,models and templates for a given Resource along with API endpoints and Unit tests.

Features include

  • Python 3 Support
  • RESTFUL JSON API
  • Unit Testing with python Unit tests
  • End 2 End testing with Protractor
  • Continous Integration with Travis-CI
  • Inbuilt User Management and Admin Dashboard
  • Google Analytics

###Demo Sign Up and Login

Gitter PayPal donate button

###Installation

Please ensure that development libraries for PostgreSQL are installed.

####Step 1:Clone the project to your application folder.

git clone [email protected]:Leo-g/Flask-Scaffold.git YourAppFolderName && cd YourAppFolderName

####Step 2: Install the requirements and add your Database configuration details.

pip install -r requirements.txt

vim config.py
#Fill in your database username, password, name, host etc

Step 3 : Declare your Resource and it's fields in a YAML file as follows

For a list of supported fields please see https://github.com/Leo-g/Flask-Scaffold/wiki/Fields

vim scaffold/blog.yaml
posts:
 - title:string
 - body:text
 - author:string
 - creation_date:date
 - published:boolean
comments:
 - author:string
 - body:text
 - author_url:url
 - created_on:date
 - approved:boolean
authors:
 - name:string
 - profile:text
 - url:url

Step 4 : Run the Scaffolding and database migrations script

python scaffold.py scaffold/blog.yaml
python db.py db init
python db.py db migrate
python db.py db upgrade

Step 5 : Run the Server

python run.py

**You should be able to see the Login Page at http://localhost:5000, Sign Up and Login

To configure your application with nginx and uwsgi configuration see the wiki ###Tests

####For E2E testing with protractor Installation instructions for protractor are in the wiki

# To run tests for all modules
protractor conf.js

# To run a a test for a specific module

protractor app/templates/<module_name>/conf.js

####For unit testing with python Unit tests

For a Single module

python app/<module_name>/test_<module_name>.py

For all modules

bash tests.bash

###API

API calls can be made to the following URL

Note: This example is for a Post module

HTTP Method URL Results
GET http://localhost:5000/api/v1/posts.json Returns a list of all Posts
POST http://localhost:5000/api/v1/posts.json Creates a New Post
GET http://localhost:5000/api/v1/posts/1.json Returns details for the a single Post
PATCH http://localhost:5000/api/v1/posts/1.json Update a Post
DELETE http://localhost:8001/api/v1/posts/1.json Delete a Post

The JSON format follows the spec at jsonapi.org and a sample is available in the sample.json file

For details on how the API is built read http://techarena51.com/index.php/buidling-a-database-driven-restful-json-api-in-python-3-with-flask-flask-restful-and-sqlalchemy/

###Directory Structure Project-Folder |-- config.py |--run.py |--requirements.txt |--conf.js |__ /venv |-- db.py |__ /scaffold |-- scaffold.py |-- tests.bash #Tests for all modules |__ app/ |-- init.py +-- module-1 |-- init.py |-- models.py |-- test_module-1.py # Unit Tests for module 1 |-- views.py    +-- module-2 |-- init.py |-- models.py |-- test_module-2.py # Unit Tests for module 2 |-- views.py |__ templates |-- index.html |-- login.html |-- home.html +-- static + -- js |-- app.js |-- login.js |-- css |-- images +-- module-1    |-- _form.html    |-- index.html    |-- add.html    |-- update.html |-- controller.js |--conf.js |--spec.js    +-- module-2    |-- _form.html    |-- index.html    |-- add.html    |-- update.html |-- controller.js |-- conf.js |-- spec.js

Google Analytics

Add your tracking ID and Domain name in app.js in the app.config section

  app.config(function (AnalyticsProvider) {
              // Set a single account
              AnalyticsProvider.setAccount('UA-XXXXX-xx');
              AnalyticsProvider.setDomainName('XXX');

   });

For complete Documentation see the wiki

flask-scaffold's People

Contributors

jstacoder avatar zypeh avatar althea-lobo avatar

Watchers

James Cloos avatar Marcos Oliveira 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.