Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/akhilharihar/Flask-Maintenance
Maintenance mode for Flask application.
https://github.com/akhilharihar/Flask-Maintenance
Last synced: 9 days ago
JSON representation
Maintenance mode for Flask application.
- Host: GitHub
- URL: https://github.com/akhilharihar/Flask-Maintenance
- Owner: akhilharihar
- License: mit
- Created: 2019-07-06T02:11:16.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2019-07-08T05:00:39.000Z (over 5 years ago)
- Last Synced: 2024-11-05T13:07:43.086Z (about 1 month ago)
- Language: Python
- Homepage:
- Size: 4.88 KB
- Stars: 5
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- jimsghstars - akhilharihar/Flask-Maintenance - Maintenance mode for Flask application. (Python)
README
# Flask-Maintenance
Adds maintenane mode capability to your Flask app.
## Installing:
Install and update using [pip](https://pip.pypa.io/en/stable/quickstart/):
```
pip install Flask-Maintenance
```Then register this extension.
```
from flask_maintenance import Maintenanceapp = 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](http://flask.pocoo.org/docs/1.0/patterns/errorpages/#custom-error-pages).
```
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'), 503def create_app():
app = Flask(__name__)
app.register_error_handler(503, under_maintenance)
return app
```