Giter Site home page Giter Site logo

flask-template's Introduction

Duplicated Lines (%)Reliability RatingQuality Gate StatusTechnical DebtCoverageLines of CodeCode SmellsMaintainability RatingSecurity RatingBugsVulnerabilities

flask-template

This repository contains an advanced generic template app using the Flask framework.

Features

Automatic Schemas

You can automatically generate marshmallow schemas by using the add_schema() decorator on your models.

@add_schema(
    meta=[
        "exclude": ["password"]
    ],
    custom_field=ma.String(...)
)
class User(BaseModel):
    name: str = db.Column(db.String())
    password: str = db.Column(db.String())

Automatic Views

Similarily You can automatically generate views for you models by using the add_view() decorator. This will generate default REST endpoints to perform CRUD operations for the model.

Authentication and Authorization

Protect your views and endpoints by using the decorator auth.auth_required and auth.roles_required(*roles).

Third party extensions

It also features the following extensions:

  • flask-smorest
  • flask-praetorian
  • SQLAlchemy
  • SQLAlchemy-Mixins
  • Marshmallow
  • SocketIO
  • APScheduler

Usage

This template is intended to be used with Visual Studio Code.

Tasks

When opening the project, a new virtual environment will be created and the Flask server will be started.
The task can also be (re)started by using the shortcut Ctrl+Shift+B.

Configuration

The default config file path is config/config.yml.

To add more configuration options simply extend src/config.py.

Logging

Logging is done with python's default logging library. Logs are outputted by default in the console and also to logs/app.log.

Database

The default database path is data/app.sqlite.

Models are defined in src/models and should inherit from the BaseModel class in src/models/base_model.py.

Testing

Tests can be defined in src/tests/ and are automatically discovered by the VS Code Test Explorer.

Events

SocketIO events should be implemented in src/events.

Planned Features

  • Add template tests
  • Add Github workflows

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.