Flask-States is a visual plug-in based on flask. It can record the local state every minute and read redis status (optional),and generate data chart to show to users through Echarts.
Install and update using pip:
$ pip install Flask-State
After the Flask-State is installed, you also need to import JavaScript files and CSS files to bind a convention ID value for your element, which can be used easily. In some configurations, you can also choose to modify them.
import flask
app = flask.Flask(__name__)
Secondly:Call the init_app method of the Flask-State to initialize the relevant configuration. It will add several routes for you to access some configurations and databases.
import flask_state
flask_state.init_app(app)
<link href="https://cdn.jsdelivr.net/gh/yoobool/[email protected]/flask_state/static/flask_state.css" rel="stylesheet">
<!-- Any element: div/button/a/span -->
<a id='console_machine_status'></a>
<script src="https://cdn.staticfile.org/echarts/4.2.1/echarts.min.js"></script>
<script src="https://cdn.jsdelivr.net/gh/yoobool/[email protected]/flask_state/static/flask_state.js"></script>
# If you still need to monitor the redis status, you need to configure your redis status on the Flask app
app.config['REDIS_CONF'] = {'REDIS_STATE': True, 'REDIS_HOST': '192.168.1.2', 'REDIS_PORT':16379, 'REDIS_PASSWORD': 'fish09'}
from flask_state import default_conf_obj
# ADDRESS is the database name
# CATALOGUE 0 is the same level directory as Flask config, and 1 is the superior directory of Flask config
ADDRESS = 'console_host'
default_conf_obj.set_address(ADDRESS)
from flask_state import default_conf_obj
# SECS is the time interval for recording the local state, with a minimum interval of 10 seconds
SECS = 60
default_conf_obj.set_secs(SECS)
Welcome to open an issue!
Flask-State follows the Contributor Covenant Code of Conduct.
Flask-State is available under the BSD-3-Clause License.