flask-pocket


Nameflask-pocket JSON
Version 1.0.2 PyPI version JSON
download
home_pagehttps://github.com/codewithmpia/flask_pocket
SummaryFlask extension to integrate PocketBase
upload_time2025-01-31 05:28:00
maintainerNone
docs_urlNone
authorcodewithmpia
requires_pythonNone
licenseNone
keywords
VCS
bugtrack_url
requirements Flask pocketbase setuptools
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Flask Pocket

FlaskPocket is a Flask extension that integrates PocketBase, a backend service.

## Prerequisites

- [PocketBase](https://pocketbase.io/)
- [PocketBase Python SDK](https://github.com/vaphes/pocketbase)

## Installation

```bash
pip install flask-pocket
```

Or install from the cloned repository:

```bash
git clone https://github.com/codewithmpia/flask_pocket.git
cd flask_pocket
pip install .
```

## Configuration

Add the following configurations to your Flask app:

```python
app.config["POCKETBASE_URL"] = "your_pocketbase_url"
app.config["POCKETBASE_ADMIN_EMAIL"] = "your_admin_email"
app.config["POCKETBASE_ADMIN_PASSWORD"] = "your_admin_password"
```

## Usage

```python
from flask import Flask
from flask_pocket import FlaskPocket

app = Flask(__name__)

app.config["POCKETBASE_URL"] = "your_pocketbase_url"
app.config["POCKETBASE_ADMIN_EMAIL"] = "your_admin_email"
app.config["POCKETBASE_ADMIN_PASSWORD"] = "your_admin_password"
pocket = FlaskPocket(app)
```

## Queries

### Get All Objects

```python
try:
    posts = pocket.collection("posts").get_full_list()
except pocket.ClientResponseError as e:
    # Handle error
    print(f"Error: {e}")
```

### Get One Object

```python
try:
    post = pocket.collection("posts").get_one(post_id)
    # Generate image url
    image_url = pocket.client.get_file_url(post, post.image)
except pocket.ClientResponseError as e:
    # Handle error
    print(f"Error: {e}")
```

### Create

```python
try:
    pocket.collection("contacts").create({
        "name": name,
        "email": email,
        "message": message
    })
    return redirect(url_for("contact"))
except pocket.ClientResponseError as e:
    # Handle error
    print(f"Error: {e}")
```

### Edit

```python
try:
    pocket.collection("contacts").update(contact_id, {
        "name": new_name,
        "email": new_email,
        "message": new_message
    })
except pocket.ClientResponseError as e:
    # Handle error
    print(f"Error: {e}")
```

### Delete

```python
try:
    pocket.collection("contacts").delete(contact_id)
except pocket.ClientResponseError as e:
    # Handle error
    print(f"Error: {e}")
```

## License
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.

## Contributions

Contributions are welcome.


            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/codewithmpia/flask_pocket",
    "name": "flask-pocket",
    "maintainer": null,
    "docs_url": null,
    "requires_python": null,
    "maintainer_email": null,
    "keywords": null,
    "author": "codewithmpia",
    "author_email": "codewithmpia@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/50/83/1d2f5ed408cbabbed4280bb0001bb3edcf5500f98a523b7a2b7816c0551c/flask_pocket-1.0.2.tar.gz",
    "platform": null,
    "description": "# Flask Pocket\n\nFlaskPocket is a Flask extension that integrates PocketBase, a backend service.\n\n## Prerequisites\n\n- [PocketBase](https://pocketbase.io/)\n- [PocketBase Python SDK](https://github.com/vaphes/pocketbase)\n\n## Installation\n\n```bash\npip install flask-pocket\n```\n\nOr install from the cloned repository:\n\n```bash\ngit clone https://github.com/codewithmpia/flask_pocket.git\ncd flask_pocket\npip install .\n```\n\n## Configuration\n\nAdd the following configurations to your Flask app:\n\n```python\napp.config[\"POCKETBASE_URL\"] = \"your_pocketbase_url\"\napp.config[\"POCKETBASE_ADMIN_EMAIL\"] = \"your_admin_email\"\napp.config[\"POCKETBASE_ADMIN_PASSWORD\"] = \"your_admin_password\"\n```\n\n## Usage\n\n```python\nfrom flask import Flask\nfrom flask_pocket import FlaskPocket\n\napp = Flask(__name__)\n\napp.config[\"POCKETBASE_URL\"] = \"your_pocketbase_url\"\napp.config[\"POCKETBASE_ADMIN_EMAIL\"] = \"your_admin_email\"\napp.config[\"POCKETBASE_ADMIN_PASSWORD\"] = \"your_admin_password\"\npocket = FlaskPocket(app)\n```\n\n## Queries\n\n### Get All Objects\n\n```python\ntry:\n    posts = pocket.collection(\"posts\").get_full_list()\nexcept pocket.ClientResponseError as e:\n    # Handle error\n    print(f\"Error: {e}\")\n```\n\n### Get One Object\n\n```python\ntry:\n    post = pocket.collection(\"posts\").get_one(post_id)\n    # Generate image url\n    image_url = pocket.client.get_file_url(post, post.image)\nexcept pocket.ClientResponseError as e:\n    # Handle error\n    print(f\"Error: {e}\")\n```\n\n### Create\n\n```python\ntry:\n    pocket.collection(\"contacts\").create({\n        \"name\": name,\n        \"email\": email,\n        \"message\": message\n    })\n    return redirect(url_for(\"contact\"))\nexcept pocket.ClientResponseError as e:\n    # Handle error\n    print(f\"Error: {e}\")\n```\n\n### Edit\n\n```python\ntry:\n    pocket.collection(\"contacts\").update(contact_id, {\n        \"name\": new_name,\n        \"email\": new_email,\n        \"message\": new_message\n    })\nexcept pocket.ClientResponseError as e:\n    # Handle error\n    print(f\"Error: {e}\")\n```\n\n### Delete\n\n```python\ntry:\n    pocket.collection(\"contacts\").delete(contact_id)\nexcept pocket.ClientResponseError as e:\n    # Handle error\n    print(f\"Error: {e}\")\n```\n\n## License\nThis project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.\n\n## Contributions\n\nContributions are welcome.\n\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "Flask extension to integrate PocketBase",
    "version": "1.0.2",
    "project_urls": {
        "Author": "https://github.com/codewithmpia",
        "Homepage": "https://github.com/codewithmpia/flask_pocket",
        "Source": "https://github.com/codewithmpia/flask_pocket",
        "Tracker": "https://github.com/codewithmpia/flask_pocket/issues"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "525950d0650cbda266b2bc20cd1c22e144780c0f6792307aeef8fd36cd1ab6ed",
                "md5": "d03dc4668b46656a16c1b63e661292e0",
                "sha256": "cb43528cd61928aaa31a29d22117806c572e8f59be24d648e8f8b2ed673d6fe5"
            },
            "downloads": -1,
            "filename": "flask_pocket-1.0.2-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "d03dc4668b46656a16c1b63e661292e0",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 4015,
            "upload_time": "2025-01-31T05:27:58",
            "upload_time_iso_8601": "2025-01-31T05:27:58.739229Z",
            "url": "https://files.pythonhosted.org/packages/52/59/50d0650cbda266b2bc20cd1c22e144780c0f6792307aeef8fd36cd1ab6ed/flask_pocket-1.0.2-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "50831d2f5ed408cbabbed4280bb0001bb3edcf5500f98a523b7a2b7816c0551c",
                "md5": "9f3ae3c5c2987da4551e9d5c1ccfa739",
                "sha256": "8c86bf141229d32a06ae12ebde5f37c14257911fc90067f6bde68b8a51f332bd"
            },
            "downloads": -1,
            "filename": "flask_pocket-1.0.2.tar.gz",
            "has_sig": false,
            "md5_digest": "9f3ae3c5c2987da4551e9d5c1ccfa739",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 3720,
            "upload_time": "2025-01-31T05:28:00",
            "upload_time_iso_8601": "2025-01-31T05:28:00.434977Z",
            "url": "https://files.pythonhosted.org/packages/50/83/1d2f5ed408cbabbed4280bb0001bb3edcf5500f98a523b7a2b7816c0551c/flask_pocket-1.0.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-01-31 05:28:00",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "codewithmpia",
    "github_project": "flask_pocket",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "requirements": [
        {
            "name": "Flask",
            "specs": []
        },
        {
            "name": "pocketbase",
            "specs": []
        },
        {
            "name": "setuptools",
            "specs": []
        }
    ],
    "lcname": "flask-pocket"
}
        
Elapsed time: 0.74257s