A flask extension to log a python object in json file
Project description
flask-json-db
A flask extension to log a variable value inside view in a JSON file
Installation
- For stable version
pip install flask-json-db
- For developement
cd flask-json-db
python -m venv .venv
source .venv/bin/activate
Example
from flask import Flask
from flask_json_db import JSONDB
app = Flask(__name__)
app.config["JSONFILE"] = "custom.json" #optional
json_db = JSONDB(app)
@app.route('/')
def hello_world():
json_db.write({"landing_view_var":"landing_view_var_value"})
return 'Hello World'
@app.route("/home")
def home():
json_db.write({"home_var":["jshajdhjs"]})
return 'ghj'
@app.route("/new_home")
def new_home():
db.write({"new_home_var": "new_home_var_value"})
return "hjk"
if __name__ == '__main__':
app.run()
open the custom.json and get to know about these variable values
General Info
I don’t know how can it be helpful but it is helpful for me :)
Contributing
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
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-json-db-0.0.1.tar.gz
(2.9 kB
view details)
Built Distribution
File details
Details for the file flask-json-db-0.0.1.tar.gz
.
File metadata
- Download URL: flask-json-db-0.0.1.tar.gz
- Upload date:
- Size: 2.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.8.10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2b99ebc2d5de5989137451953bd786fd56851a9a586e3ac1ae480abb51a9289b |
|
MD5 | 0336b55b5d8b7c0f845ad5d63a746c3c |
|
BLAKE2b-256 | 7d4b2f5bfde2fc677cde4fb16d0f9962fdcac0d66f0ad27cfc92636bde6d0e32 |
File details
Details for the file flask_json_db-0.0.1-py3-none-any.whl
.
File metadata
- Download URL: flask_json_db-0.0.1-py3-none-any.whl
- Upload date:
- Size: 3.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.8.10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f81e437396fcdfa8872a023c571cc12e1273198d684ba81202435fb82b04c5c7 |
|
MD5 | 8cafe3e7102d29ec59f2374e59dd5617 |
|
BLAKE2b-256 | 71fcff91da929a542a5112f69bc0b4f2c66084ac1069bb5709b932114db4a604 |