flask-deta


Nameflask-deta JSON
Version 0.2.1 PyPI version JSON
download
home_page
SummaryA Python library for seamless integration with DetaSpace in Flask
upload_time2023-08-22 18:13:05
maintainerJ.P. Esparza
docs_urlNone
authorJ.P. Esparza
requires_python>=3.10
licenseBSD-3 Clause License Copyright (c) 2023 J.P. Esparza Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. Neither the name of J.P. Esparza nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
keywords databases deta detaspace drive fask deta flask flask nosql flask package nosql python deta web development
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            ## Version 0.2.1
> ⚠️ This is the initial version 0.2.1 and is currently in the alpha stage. It is not recommended for production use.

---

**Welcome to FlaskDeta README!**

**For a more detailed use, I recommend you to visit the [Flask-Deta documentation](https://flask-deta.readthedocs.io/en/latest/)**

Flask-Deta is a Python library that simplifies the integration of your [DetaSpace](https://deta.space/) collection of database and/or drive files with [Flask](https://flask.palletsprojects.com/en/2.3.x/) framework. 

With Flask-Deta, you can store and manage data with `DetaBase` and handle file storage operations with `DetaDrive`, all within the context of your Flask application. This robust combination allows you to leverage the secure and scalable cloud infrastructure of [DetaSpace](https://deta.space/), making data and file management for your web projects convenient. 

In this documents, we will provide you with an in-depth overview of Flask-Deta and help you get started using this extraordinary tool.

> We'd like to inform you that not all DetaSpace functionalities are currently integrated, both in Drive and Base. However, we are working on gradually incorporating them to create a robust integration package between Flask and DetaSpace. Our aim is to enhance your development experience by leveraging the full potential of this integration.

- To learn more about DetaSpace visit the [DetaSpace documentation](https://deta.space/docs/en/).
- To learn more about Flask visit the [Flask documentation](https://flask.palletsprojects.com/en/2.3.x/).

# Install
```shell
pip install flask-deta
```

# QuickStart

1. **Create a Flask App:** Begin by creating an instance of the Flask app in your Python code.

2. **Set Configuration Parameters:** Set the required parameters, such as your Deta project key, Base name, and Drive name.

3. **Create DetaBase and DetaDrive Instances:** Create instances of DetaBase and DetaDrive using your Flask `app` as an argument.


## DetaBase
```python
from flask import Flask
from flask_deta import DetaBase

app = Flask(__name__)

# Set the DetaSpace project key and database name
app.config["DETA_PROJECT_KEY"] = "MyKey12345"
app.config["BASE_NAME"] = "products" # DetaSpace Base for data 

# Create instance of DetaBase
base = DetaBase(app)

# DetaBase.get_all()
@app.route("/data")
def all_records():
    data = base.get_all()
    return data

if __name__ == "__main__":
    app.run(debug=True)
```

## DetaDrive
```python
from flask import Flask
from flask_deta import DetaDrive

app = Flask(__name__)

# Set the DetaSpace project key and drive name
app.config["DETA_PROJECT_KEY"] = "MyKey12345"
app.config["DRIVE_NAME"] = "icons" # DetaSpace Drive for files

# Create instances of DetaDrive
drive = DetaDrive(app)

# DetaDrive.all_files()
@app.route("/files")
def all_files():
    files = drive.all_files()
    return files

if __name__ == "__main__":
    app.run(debug=True)
```

## DetaDrive + DetaBase
```python
from flask import Flask
from flask_deta import DetaBase, DetaDrive

app = Flask(__name__)

# Set the DetaSpace project key, database name and drive name
app.config["DETA_PROJECT_KEY"] = "MyKey12345"
app.config["BASE_NAME"] = "products" # DetaSpace Base for data 
app.config["DRIVE_NAME"] = "icons" # DetaSpace Drive for files

# Create instances of DetaDrive and DetaBase
base = DetaBase(app)
drive = DetaDrive(app)

# DetaBase.get_all()
@app.route("/data")
def all_records():
    data = base.get_all()
    return data

# DetaDrive.all_files()
@app.route("/files")
def all_files():
    files = drive.all_files()
    return files

if __name__ == "__main__":
    app.run(debug=True)
```

## Using `init_app()`
To ensure modularity and easy integration, the `init_app()` method is provided for initializing both DetaBase and DetaDrive separately. This approach allows you to configure and associate the extensions with your Flask application in a standardized manner.

### DetaBase.`init_app`
```python
from flask import Flask
from flask_deta import DetaBase

app = Flask(__name__)

# Set the DetaSpace project key and database name
app.config["DETA_PROJECT_KEY"] = "MyKey12345"
app.config["BASE_NAME"] = "products" # DetaSpace Base for data 

# Create an instance of DetaBase
base = DetaBase()

@app.route("/all")
def all_data():
    data = base.get_all()
    return data

base.init_app(app)

if __name__ == "__main__":
    app.run(debug=True)
```

### DetaDrive.`init_app`
```python
from flask import Flask
from flask_deta import DetaDrive

app = Flask(__name__)

# Set the DetaSpace project key and drive name
app.config["DETA_PROJECT_KEY"] = "MyKey12345"
app.config["DRIVE_NAME"] = "icons" # DetaSpace Drive for files

# Create an instance of DetaDrive
drive = DetaDrive()

@app.route("/files")
def files():
    files = drive.all_files()
    return files

drive.init_app(app)

if __name__ == "__main__":
    app.run(debug=True)
```

### DetaBase.init_app + DetaDrive.init_app
```python
app = Flask(__name__)

# Set the DetaSpace project key and drive name
app.config["DETA_PROJECT_KEY"] = "MyKey12345"
app.config["BASE_NAME"] = "products"  # DetaSpace Base for data
app.config["DRIVE_NAME"] = "icons"  # DetaSpace Drive for files

# Create instances of DetaDrive and DetaBase
base = DetaBase()
drive = DetaDrive()

# Home
@app.route("/")
def home():
    links = """
    <head>
        <title>Flask-Deta</title>
        <style>
            body {
                background: antiquewhite;
                color: white;
                font-family: Arial, sans-serif;
                text-align: center;
            }

            h1 {
                color: darkslateblue;
            }

            a {
                display: block;
                margin: 10px auto;
                padding: 10px;
                width: 200px;
                background-color: deepskyblue;
                color: white;
                text-decoration: none;
                border-radius: 5px;
                transition: background-color 0.3s ease-in-out;
            }

            a:hover {
                background-color: dodgerblue;
            }
        </style>
    </head>
    <body>
        <h1>Welcome to Flask-Deta</h1>
        <div>
            <a href="/data" target="_blank">
                Get all data list
            </a>
            <a href="/files" target="_blank">
                Get all files list
            </a>
        </div>
    </body>
    """
    return links


# DetaBase.get_all()
@app.route("/data")
def all_records():
    data = base.get_all()
    return data

# DetaDrive.all_files()
@app.route("/files")
def all_files():
    files = drive.all_files()
    return files


base.init_app(app)
drive.init_app(app)

if __name__ == "__main__":
    app.run(debug=True)
```

Visit the [Flask-Deta documentation](https://flask-deta.readthedocs.io/en/latest/)
            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "flask-deta",
    "maintainer": "J.P. Esparza",
    "docs_url": null,
    "requires_python": ">=3.10",
    "maintainer_email": "",
    "keywords": "Databases,Deta,Detaspace,Drive,Fask Deta,Flask,Flask NoSQL,Flask Package,NoSQL,Python Deta,Web Development",
    "author": "J.P. Esparza",
    "author_email": "",
    "download_url": "https://files.pythonhosted.org/packages/dc/a3/2523f3f4ccd8ecc1ba9e6ea980a06bd5d952dd542bc6ab6c3dd9d7477c81/flask_deta-0.2.1.tar.gz",
    "platform": null,
    "description": "## Version 0.2.1\n> \u26a0\ufe0f This is the initial version 0.2.1 and is currently in the alpha stage. It is not recommended for production use.\n\n---\n\n**Welcome to FlaskDeta README!**\n\n**For a more detailed use, I recommend you to visit the [Flask-Deta documentation](https://flask-deta.readthedocs.io/en/latest/)**\n\nFlask-Deta is a Python library that simplifies the integration of your [DetaSpace](https://deta.space/) collection of database and/or drive files with [Flask](https://flask.palletsprojects.com/en/2.3.x/) framework. \n\nWith Flask-Deta, you can store and manage data with `DetaBase` and handle file storage operations with `DetaDrive`, all within the context of your Flask application. This robust combination allows you to leverage the secure and scalable cloud infrastructure of [DetaSpace](https://deta.space/), making data and file management for your web projects convenient. \n\nIn this documents, we will provide you with an in-depth overview of Flask-Deta and help you get started using this extraordinary tool.\n\n> We'd like to inform you that not all DetaSpace functionalities are currently integrated, both in Drive and Base. However, we are working on gradually incorporating them to create a robust integration package between Flask and DetaSpace. Our aim is to enhance your development experience by leveraging the full potential of this integration.\n\n- To learn more about DetaSpace visit the [DetaSpace documentation](https://deta.space/docs/en/).\n- To learn more about Flask visit the [Flask documentation](https://flask.palletsprojects.com/en/2.3.x/).\n\n# Install\n```shell\npip install flask-deta\n```\n\n# QuickStart\n\n1. **Create a Flask App:** Begin by creating an instance of the Flask app in your Python code.\n\n2. **Set Configuration Parameters:** Set the required parameters, such as your Deta project key, Base name, and Drive name.\n\n3. **Create DetaBase and DetaDrive Instances:** Create instances of DetaBase and DetaDrive using your Flask `app` as an argument.\n\n\n## DetaBase\n```python\nfrom flask import Flask\nfrom flask_deta import DetaBase\n\napp = Flask(__name__)\n\n# Set the DetaSpace project key and database name\napp.config[\"DETA_PROJECT_KEY\"] = \"MyKey12345\"\napp.config[\"BASE_NAME\"] = \"products\" # DetaSpace Base for data \n\n# Create instance of DetaBase\nbase = DetaBase(app)\n\n# DetaBase.get_all()\n@app.route(\"/data\")\ndef all_records():\n    data = base.get_all()\n    return data\n\nif __name__ == \"__main__\":\n    app.run(debug=True)\n```\n\n## DetaDrive\n```python\nfrom flask import Flask\nfrom flask_deta import DetaDrive\n\napp = Flask(__name__)\n\n# Set the DetaSpace project key and drive name\napp.config[\"DETA_PROJECT_KEY\"] = \"MyKey12345\"\napp.config[\"DRIVE_NAME\"] = \"icons\" # DetaSpace Drive for files\n\n# Create instances of DetaDrive\ndrive = DetaDrive(app)\n\n# DetaDrive.all_files()\n@app.route(\"/files\")\ndef all_files():\n    files = drive.all_files()\n    return files\n\nif __name__ == \"__main__\":\n    app.run(debug=True)\n```\n\n## DetaDrive + DetaBase\n```python\nfrom flask import Flask\nfrom flask_deta import DetaBase, DetaDrive\n\napp = Flask(__name__)\n\n# Set the DetaSpace project key, database name and drive name\napp.config[\"DETA_PROJECT_KEY\"] = \"MyKey12345\"\napp.config[\"BASE_NAME\"] = \"products\" # DetaSpace Base for data \napp.config[\"DRIVE_NAME\"] = \"icons\" # DetaSpace Drive for files\n\n# Create instances of DetaDrive and DetaBase\nbase = DetaBase(app)\ndrive = DetaDrive(app)\n\n# DetaBase.get_all()\n@app.route(\"/data\")\ndef all_records():\n    data = base.get_all()\n    return data\n\n# DetaDrive.all_files()\n@app.route(\"/files\")\ndef all_files():\n    files = drive.all_files()\n    return files\n\nif __name__ == \"__main__\":\n    app.run(debug=True)\n```\n\n## Using `init_app()`\nTo ensure modularity and easy integration, the `init_app()` method is provided for initializing both DetaBase and DetaDrive separately. This approach allows you to configure and associate the extensions with your Flask application in a standardized manner.\n\n### DetaBase.`init_app`\n```python\nfrom flask import Flask\nfrom flask_deta import DetaBase\n\napp = Flask(__name__)\n\n# Set the DetaSpace project key and database name\napp.config[\"DETA_PROJECT_KEY\"] = \"MyKey12345\"\napp.config[\"BASE_NAME\"] = \"products\" # DetaSpace Base for data \n\n# Create an instance of DetaBase\nbase = DetaBase()\n\n@app.route(\"/all\")\ndef all_data():\n    data = base.get_all()\n    return data\n\nbase.init_app(app)\n\nif __name__ == \"__main__\":\n    app.run(debug=True)\n```\n\n### DetaDrive.`init_app`\n```python\nfrom flask import Flask\nfrom flask_deta import DetaDrive\n\napp = Flask(__name__)\n\n# Set the DetaSpace project key and drive name\napp.config[\"DETA_PROJECT_KEY\"] = \"MyKey12345\"\napp.config[\"DRIVE_NAME\"] = \"icons\" # DetaSpace Drive for files\n\n# Create an instance of DetaDrive\ndrive = DetaDrive()\n\n@app.route(\"/files\")\ndef files():\n    files = drive.all_files()\n    return files\n\ndrive.init_app(app)\n\nif __name__ == \"__main__\":\n    app.run(debug=True)\n```\n\n### DetaBase.init_app + DetaDrive.init_app\n```python\napp = Flask(__name__)\n\n# Set the DetaSpace project key and drive name\napp.config[\"DETA_PROJECT_KEY\"] = \"MyKey12345\"\napp.config[\"BASE_NAME\"] = \"products\"  # DetaSpace Base for data\napp.config[\"DRIVE_NAME\"] = \"icons\"  # DetaSpace Drive for files\n\n# Create instances of DetaDrive and DetaBase\nbase = DetaBase()\ndrive = DetaDrive()\n\n# Home\n@app.route(\"/\")\ndef home():\n    links = \"\"\"\n    <head>\n        <title>Flask-Deta</title>\n        <style>\n            body {\n                background: antiquewhite;\n                color: white;\n                font-family: Arial, sans-serif;\n                text-align: center;\n            }\n\n            h1 {\n                color: darkslateblue;\n            }\n\n            a {\n                display: block;\n                margin: 10px auto;\n                padding: 10px;\n                width: 200px;\n                background-color: deepskyblue;\n                color: white;\n                text-decoration: none;\n                border-radius: 5px;\n                transition: background-color 0.3s ease-in-out;\n            }\n\n            a:hover {\n                background-color: dodgerblue;\n            }\n        </style>\n    </head>\n    <body>\n        <h1>Welcome to Flask-Deta</h1>\n        <div>\n            <a href=\"/data\" target=\"_blank\">\n                Get all data list\n            </a>\n            <a href=\"/files\" target=\"_blank\">\n                Get all files list\n            </a>\n        </div>\n    </body>\n    \"\"\"\n    return links\n\n\n# DetaBase.get_all()\n@app.route(\"/data\")\ndef all_records():\n    data = base.get_all()\n    return data\n\n# DetaDrive.all_files()\n@app.route(\"/files\")\ndef all_files():\n    files = drive.all_files()\n    return files\n\n\nbase.init_app(app)\ndrive.init_app(app)\n\nif __name__ == \"__main__\":\n    app.run(debug=True)\n```\n\nVisit the [Flask-Deta documentation](https://flask-deta.readthedocs.io/en/latest/)",
    "bugtrack_url": null,
    "license": "BSD-3 Clause License  Copyright (c) 2023 J.P. Esparza  Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:  1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.  2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.  3. Neither the name of J.P. Esparza nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.",
    "summary": "A Python library for seamless integration with DetaSpace in Flask",
    "version": "0.2.1",
    "project_urls": {
        "Bug Tracker": "https://github.com/Jesparzarom/Flask-Deta/issues",
        "Homepage": "https://flask-deta.readthedocs.io/en/latest/",
        "Source Code": "https://github.com/Jesparzarom/Flask-Deta"
    },
    "split_keywords": [
        "databases",
        "deta",
        "detaspace",
        "drive",
        "fask deta",
        "flask",
        "flask nosql",
        "flask package",
        "nosql",
        "python deta",
        "web development"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "9146d12807b50883419d9b6b5289e5b109e8c43f167017022e70d009073659e6",
                "md5": "e56b9888490ba445c8ae9e3ac6a7b68c",
                "sha256": "90cd51c622e23e472b76787595427c2e3085f404d2922de4ad9e97fc8b0e073f"
            },
            "downloads": -1,
            "filename": "flask_deta-0.2.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "e56b9888490ba445c8ae9e3ac6a7b68c",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.10",
            "size": 11348,
            "upload_time": "2023-08-22T18:13:03",
            "upload_time_iso_8601": "2023-08-22T18:13:03.133025Z",
            "url": "https://files.pythonhosted.org/packages/91/46/d12807b50883419d9b6b5289e5b109e8c43f167017022e70d009073659e6/flask_deta-0.2.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "dca32523f3f4ccd8ecc1ba9e6ea980a06bd5d952dd542bc6ab6c3dd9d7477c81",
                "md5": "f996d6ec4b613658e5ee4186a620b4e6",
                "sha256": "0754801e6fa2d43035325723d803c0b401faa7718becf54214db11e5ce747edf"
            },
            "downloads": -1,
            "filename": "flask_deta-0.2.1.tar.gz",
            "has_sig": false,
            "md5_digest": "f996d6ec4b613658e5ee4186a620b4e6",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.10",
            "size": 361507,
            "upload_time": "2023-08-22T18:13:05",
            "upload_time_iso_8601": "2023-08-22T18:13:05.587030Z",
            "url": "https://files.pythonhosted.org/packages/dc/a3/2523f3f4ccd8ecc1ba9e6ea980a06bd5d952dd542bc6ab6c3dd9d7477c81/flask_deta-0.2.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-08-22 18:13:05",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "Jesparzarom",
    "github_project": "Flask-Deta",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "flask-deta"
}
        
Elapsed time: 0.15342s