Coder Social home page Coder Social logo

flask-maintenance's Introduction

Flask-Maintenance

Adds maintenane mode capability to your Flask app.

Installing:

Install and update using pip:

pip install Flask-Maintenance

Then register this extension.

from flask_maintenance import Maintenance

app = Flask(__name__)
Maintenance(app)

Like other Flask extensions, you can register it lazily:

maintenance_mode = Maintenance()

def create_app():
    app = Flask(__name__)
    maintenance_mode.init_app(app)

Usage

To enable Maintenance mode, run the following command:

$ flask maintenance enable

To disable Maintenance mode:

$ flask maintenance disable

Custom template for Maintenance mode

To show a custom template to user when the maintenance mode is enabled, register a 503 Custom Error Handler.

from flask import render_template

@app.errorhandler(503)
def under_maintenance(e):
    return render_template('503.html'), 503

If you are using application factory pattern:

def under_maintenance(e):
    return render_template('503.html'), 503

def create_app():
    app = Flask(__name__)
    app.register_error_handler(503, under_maintenance)
    return app

flask-maintenance's People

Contributors

akhilharihar avatar

Stargazers

 avatar Jimmy Briggs avatar  avatar Ritvik Khanna avatar Tomas Pytel avatar

Watchers

James Cloos 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.