Skip to main content

Create a variable manager in flask, enter values in python, and use values on the jinja template.

Project description

Flask Variable Manager

The Flask Variable Manager is a Flask extension that allows you to manage variables within your Flask application.

It provides an interface to set and get variables, and even render them in Jinja2 templates.

This can be useful when you need to share data across different parts of your application.

Installation

To install the Flask Variable Manager, you can use pip:

pip install flask-variable-manager

Usage

First, import the VariableManagerExtension from the flask_variable_manager package:

Then, create an instance of the VariableManagerExtension and initialize it with your Flask application:

from flask import Flask
from flask_variable_manager import VariableManagerExtension

vm = VariableManagerExtension()
app = Flask(__name__)
vm.init_app(app)

Now, you can use the VariableManagerExtension to set and get variables in your Flask routes.

vm._local['my_var'] = 'Hello, World!'
vm._local['my_var']

Routes

Render a string as a Jinja2 template

This route allows you to render a string as a Jinja2 template.

It accepts a POST request at the /vm/render endpoint.

Set a user-defined variable

This route allows you to set a user-defined variable.

It accepts a POST request at the /vm/var endpoint.

Get all user-defined variables

This route allows you to get all user-defined variables.

It accepts a GET request at the /vm/var endpoint.

(or vm/vars for the multiple count of the variable)

Remove a user-defined variable

This route allows you to remove a user-defined variable.

It accepts a DELETE request at the /vm/var endpoint.

(or vm/vars for the multiple count of the variable)

Run a Python script and return the result

This route allows you to run a Python script and return the result.

It accepts a POST request at the /py/runner endpoint.

import platform
from flask import g
data = additionalProp + "-" + platform.platform()
g.local['saved_user_variable'] = data
return data

Check the list of packages

This route allows you to check the list of python packages.

It accepts a GET request at the /py/packages endpoint.

install and uninstall a package

This route allows you to install and uninstall a python package.

It accepts a POST request at the /py/install, /py/uninstall endpoint.

License

This project is licensed under the terms of the MIT license.

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

flask_variable_manager-0.4.1.tar.gz (5.6 kB view details)

Uploaded Source

Built Distribution

flask_variable_manager-0.4.1-py3-none-any.whl (6.3 kB view details)

Uploaded Python 3

File details

Details for the file flask_variable_manager-0.4.1.tar.gz.

File metadata

File hashes

Hashes for flask_variable_manager-0.4.1.tar.gz
Algorithm Hash digest
SHA256 5e4a0b00f6fc744e7484039a76b5ccc3a5b671d53b20302669dfaec193bf5100
MD5 1d479ee3d6e2b03fd2e0026d3a7dc9c2
BLAKE2b-256 5d4795d28bbba52651ac73af99800953a30fe9e915c81c5d366542ec4320cfd1

See more details on using hashes here.

File details

Details for the file flask_variable_manager-0.4.1-py3-none-any.whl.

File metadata

File hashes

Hashes for flask_variable_manager-0.4.1-py3-none-any.whl
Algorithm Hash digest
SHA256 db831fad94fd0d6a62ac8c61427f85c8d3daea4b82ae5b9d07edf44689f3a429
MD5 f6f6d1b6a5513583dbc5c3dbb9338480
BLAKE2b-256 87fc9436678a8d1062dc56e4a42871e57d4573e7beddf9ed3fec6c4181f13b33

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page