flask-file-explorer


Nameflask-file-explorer JSON
Version 0.1.1 PyPI version JSON
download
home_pagehttps://github.com/thevgergroup/flask-file-explorer
SummaryA flask based file explorer
upload_time2024-02-08 20:14:06
maintainer
docs_urlNone
authorpatrick o'leary
requires_python>=3.11,<4.0
licenseMIT
keywords flask filesystem viewer explorer htmx
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # flask-file-explorer
- [flask-file-explorer](#flask-file-explorer)
  - [Why](#why)
  - [Features](#features)
  - [A quick and easy web based file explorer](#a-quick-and-easy-web-based-file-explorer)
  - [Installation](#installation)
  - [Security](#security)
    - [Flask-Login with a blueprint](#flask-login-with-a-blueprint)


## Why
This tool is just a simple flask tool to view a configurable file system in flask.
Handy for docker deployments, debugging, validating something is in the right place etc...

There is no security built into it, so you have to bring your own.
See [Flask-Login with a blueprint](#flask-login-with-a-blueprint) as an example.



## Features
~~Todos~~ ToDones: 
- [X] Upload forms aware of current directory
- [X] Drag & Drop Upload
- [X] Visual treatment of current directory
- [X] Folder and File listing
- [X] Blueprint
- [X] Dynamic data retrieval
- [X] Collapsing tree structure
- [X] Remove closed directory tree
- [X] Secure file browsing and uploads
- [ ] Custom theming and embedding 

## A quick and easy web based file explorer

Flask-file-explorer supports navigating through directories, viewing files, downloading / uploading files

* File System Explorer

<img src="https://raw.githubusercontent.com/thevgergroup/flask-file-explorer/main/docs/images/flask_file_explorer.png" width="400px" height="300px" alt="Flask File Explorer">


* File Viewer
 
<img src="https://raw.githubusercontent.com/thevgergroup/flask-file-explorer/main/docs/images/flask_file_view.png" alt="Flask File Viewer" width="400px" height="300px">

## Installation 
Standard install

```sh
poetry add flask-file-explorer
# or
pip install flask-file-explorer
# or 
poetry add git+https://github.com/thevgergroup/flask-file-explorer
```

Within your flask app, simply add the file explorer blueprint and specify the directory to limit access to

```python
'''
This is the main file of the Flask application.
It registers the file_explorer blueprint and starts the server.
'''
from flask import Flask

from flask_file_explorer.file_explorer import file_explorer_bp  # The blueprint code
from flask_file_explorer.filters import register_filters        # Filters used in the viewer

app = Flask(__name__)

app.config["FFE_BASE_DIRECTORY"] = 'flask_file_explorer/static'         # The directory the explorer is limited to
app.register_blueprint(file_explorer_bp, url_prefix='/file-explorer')   # Add the blueprint to the flask app
register_filters(app)                                                   # Register the filter



if __name__ == '__main__':
    app.run()

```

Once your start your app, you should be able to go to http://..../file-explorer/browse


## Security

There are a couple of security items
1. All file paths are verified as being in the FFE_BASE_DIRECTORY 
   * The absolute path is used to verify the file and it's relativity to the FFE_BASE_DIRECTORY 
2. Authentication and Authorization are a bring your own model
   * Example provided below


### Flask-Login with a blueprint


```python
from flask import Flask, Response, redirect, url_for, request, session, abort
from flask_login import LoginManager, UserMixin, current_user, \
                                login_required, login_url, login_user, logout_user 
                                
from flask_file_explorer.file_explorer import file_explorer_bp  # The blueprint code
from flask_file_explorer.filters import register_filters        # Filters used in the viewer


app = Flask(__name__)


app.config["FFE_BASE_DIRECTORY"] = 'templates'         # The directory the explorer is limited to
app.register_blueprint(file_explorer_bp, url_prefix='/file-explorer')   # Add the blueprint to the flask app
register_filters(app)                                                   # Register the filter

@app.before_request
def check_for_login():
    # Define a list of protected routes within the third-party blueprint
    protected_routes = '/file-explorer'
    if request.path.startswith(protected_routes):
        if not current_user.is_authenticated:
            # Redirect to login page if the user is not authenticated
            return redirect(login_url('login', request.url))



```




            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/thevgergroup/flask-file-explorer",
    "name": "flask-file-explorer",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.11,<4.0",
    "maintainer_email": "",
    "keywords": "flask,filesystem,viewer,explorer,htmx",
    "author": "patrick o'leary",
    "author_email": "pjaol@pjaol.com",
    "download_url": "https://files.pythonhosted.org/packages/f7/af/5bbd79b08c0674ba570798f98edb5f38dc13d59060f899b70f599dc4afac/flask_file_explorer-0.1.1.tar.gz",
    "platform": null,
    "description": "# flask-file-explorer\n- [flask-file-explorer](#flask-file-explorer)\n  - [Why](#why)\n  - [Features](#features)\n  - [A quick and easy web based file explorer](#a-quick-and-easy-web-based-file-explorer)\n  - [Installation](#installation)\n  - [Security](#security)\n    - [Flask-Login with a blueprint](#flask-login-with-a-blueprint)\n\n\n## Why\nThis tool is just a simple flask tool to view a configurable file system in flask.\nHandy for docker deployments, debugging, validating something is in the right place etc...\n\nThere is no security built into it, so you have to bring your own.\nSee [Flask-Login with a blueprint](#flask-login-with-a-blueprint) as an example.\n\n\n\n## Features\n~~Todos~~ ToDones: \n- [X] Upload forms aware of current directory\n- [X] Drag & Drop Upload\n- [X] Visual treatment of current directory\n- [X] Folder and File listing\n- [X] Blueprint\n- [X] Dynamic data retrieval\n- [X] Collapsing tree structure\n- [X] Remove closed directory tree\n- [X] Secure file browsing and uploads\n- [ ] Custom theming and embedding \n\n## A quick and easy web based file explorer\n\nFlask-file-explorer supports navigating through directories, viewing files, downloading / uploading files\n\n* File System Explorer\n\n<img src=\"https://raw.githubusercontent.com/thevgergroup/flask-file-explorer/main/docs/images/flask_file_explorer.png\" width=\"400px\" height=\"300px\" alt=\"Flask File Explorer\">\n\n\n* File Viewer\n \n<img src=\"https://raw.githubusercontent.com/thevgergroup/flask-file-explorer/main/docs/images/flask_file_view.png\" alt=\"Flask File Viewer\" width=\"400px\" height=\"300px\">\n\n## Installation \nStandard install\n\n```sh\npoetry add flask-file-explorer\n# or\npip install flask-file-explorer\n# or \npoetry add git+https://github.com/thevgergroup/flask-file-explorer\n```\n\nWithin your flask app, simply add the file explorer blueprint and specify the directory to limit access to\n\n```python\n'''\nThis is the main file of the Flask application.\nIt registers the file_explorer blueprint and starts the server.\n'''\nfrom flask import Flask\n\nfrom flask_file_explorer.file_explorer import file_explorer_bp  # The blueprint code\nfrom flask_file_explorer.filters import register_filters        # Filters used in the viewer\n\napp = Flask(__name__)\n\napp.config[\"FFE_BASE_DIRECTORY\"] = 'flask_file_explorer/static'         # The directory the explorer is limited to\napp.register_blueprint(file_explorer_bp, url_prefix='/file-explorer')   # Add the blueprint to the flask app\nregister_filters(app)                                                   # Register the filter\n\n\n\nif __name__ == '__main__':\n    app.run()\n\n```\n\nOnce your start your app, you should be able to go to http://..../file-explorer/browse\n\n\n## Security\n\nThere are a couple of security items\n1. All file paths are verified as being in the FFE_BASE_DIRECTORY \n   * The absolute path is used to verify the file and it's relativity to the FFE_BASE_DIRECTORY \n2. Authentication and Authorization are a bring your own model\n   * Example provided below\n\n\n### Flask-Login with a blueprint\n\n\n```python\nfrom flask import Flask, Response, redirect, url_for, request, session, abort\nfrom flask_login import LoginManager, UserMixin, current_user, \\\n                                login_required, login_url, login_user, logout_user \n                                \nfrom flask_file_explorer.file_explorer import file_explorer_bp  # The blueprint code\nfrom flask_file_explorer.filters import register_filters        # Filters used in the viewer\n\n\napp = Flask(__name__)\n\n\napp.config[\"FFE_BASE_DIRECTORY\"] = 'templates'         # The directory the explorer is limited to\napp.register_blueprint(file_explorer_bp, url_prefix='/file-explorer')   # Add the blueprint to the flask app\nregister_filters(app)                                                   # Register the filter\n\n@app.before_request\ndef check_for_login():\n    # Define a list of protected routes within the third-party blueprint\n    protected_routes = '/file-explorer'\n    if request.path.startswith(protected_routes):\n        if not current_user.is_authenticated:\n            # Redirect to login page if the user is not authenticated\n            return redirect(login_url('login', request.url))\n\n\n\n```\n\n\n\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "A flask based file explorer",
    "version": "0.1.1",
    "project_urls": {
        "Homepage": "https://github.com/thevgergroup/flask-file-explorer",
        "Repository": "https://github.com/thevgergroup/flask-file-explorer.git"
    },
    "split_keywords": [
        "flask",
        "filesystem",
        "viewer",
        "explorer",
        "htmx"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "2e7db9a1e4d7b687e42a706c85168974a3eb889e3aa110d9695e0f6de549f323",
                "md5": "f190f1a3bafc8e99fe5f7535b45364f4",
                "sha256": "a46eaaca0c4a8af92a4455b4f5b26367ef395d2f966927899b48cdc72060d609"
            },
            "downloads": -1,
            "filename": "flask_file_explorer-0.1.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "f190f1a3bafc8e99fe5f7535b45364f4",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.11,<4.0",
            "size": 9355,
            "upload_time": "2024-02-08T20:14:04",
            "upload_time_iso_8601": "2024-02-08T20:14:04.513339Z",
            "url": "https://files.pythonhosted.org/packages/2e/7d/b9a1e4d7b687e42a706c85168974a3eb889e3aa110d9695e0f6de549f323/flask_file_explorer-0.1.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "f7af5bbd79b08c0674ba570798f98edb5f38dc13d59060f899b70f599dc4afac",
                "md5": "c6d8e4a76ba450ca70508d8a0db3a112",
                "sha256": "8d97a1f0f0d72a6fda2703fb94d9b867687a5e00eef312bb7f8d77f965546ff0"
            },
            "downloads": -1,
            "filename": "flask_file_explorer-0.1.1.tar.gz",
            "has_sig": false,
            "md5_digest": "c6d8e4a76ba450ca70508d8a0db3a112",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.11,<4.0",
            "size": 8142,
            "upload_time": "2024-02-08T20:14:06",
            "upload_time_iso_8601": "2024-02-08T20:14:06.110358Z",
            "url": "https://files.pythonhosted.org/packages/f7/af/5bbd79b08c0674ba570798f98edb5f38dc13d59060f899b70f599dc4afac/flask_file_explorer-0.1.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-02-08 20:14:06",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "thevgergroup",
    "github_project": "flask-file-explorer",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "flask-file-explorer"
}
        
Elapsed time: 0.24251s