https://github.com/agent-hellboy/flask-json-db
https://github.com/agent-hellboy/flask-json-db
Last synced: 8 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/agent-hellboy/flask-json-db
- Owner: Agent-Hellboy
- License: mit
- Created: 2022-12-20T14:27:34.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2022-12-20T14:53:00.000Z (over 3 years ago)
- Last Synced: 2025-02-09T17:05:18.726Z (over 1 year ago)
- Language: Python
- Size: 6.84 KB
- Stars: 1
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.rst
- License: LICENSE
Awesome Lists containing this project
README
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
- git clone https://github.com/Agent-Hellboy/flask-json-db
- cd flask-json-db
- python -m venv .venv
- source .venv/bin/activate
Example
=======
.. code:: py
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 'home'
@app.route("/new_home")
def new_home():
db.write({"new_home_var": "new_home_var_value"})
# this raise exception and got handled in app_teardown
return "new_home"
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.