Show local state to users through Echarts.
Project description
Flask-State
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.
Installation
Install and update using pip:
$ pip install Flask-State
Usage
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.
Firstly:we'll set up a Flask app.
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)
Thirdly:Introduce related files into your HTML file and bind ID values for an element.
<link href="https://cdn.jsdelivr.net/gh/yoobool/flask-state@v0.0.1/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/flask-state@v0.0.1/flask_state/static/flask_state.js"></script>
Extra:You can also customize some configuration files.
# 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
# ID_NAME is the ID of the binding element in HTML
# NEED_BALL is set to false to use page element binding, and true to float ball binding
ID_NAME = (False, 'console_machine_status')
default_conf_obj.set_id_name(ID_NAME, NEED_BALL)
from flask_state import default_conf_obj
# LANGUAGE is the plug-in display language, currently there are Chinese,English
LANGUAGE = 'English'
default_conf_obj.set_language(LANGUAGE)
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, CATALOGUE)
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)
Contributing
Welcome to open an issue!
Flask-State follows the Contributor Covenant Code of Conduct.
License
......
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Flask-State-0.0.2.tar.gz
(3.0 kB
view hashes)
Built Distribution
Close
Hashes for Flask_State-0.0.2-py2-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 956617f8b412cc530a18f6252eec106709cee0945584849f4247fbaa727c01bb |
|
MD5 | 661042b4ed902f2ffac14368880a6a13 |
|
BLAKE2b-256 | f4eeac12c1b8f3e7b37bb3fbd2d636bc4e457ea8818c6ecd70359d0ec8ca9a9e |