flask-file-share


Nameflask-file-share JSON
Version 0.1.2 PyPI version JSON
download
home_pagehttps://flask-file-share.readthedocs.io
SummaryFlask-based file sharing with web interface, API, and CLI app
upload_time2024-04-28 16:54:53
maintainerHermann Agossou
docs_urlNone
authorhermann-web
requires_python<4.0.0,>=3.8.1
licenseMIT
keywords flask file sharing web interface api cli
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # File Sharing App

__A Flask-based file sharing application with enhanced functionalities.__

This Flask-based file sharing app provides a user-friendly interface for accessing files uploaded to the server. It allows users to upload, download, and view files through a web interface. Additionally, it provides an API and a CLI App for programmatic access to file management functionalities.

## Features

- __User Authentication:__

  - Users can log in with a username and password to access the file manager's functionalities.
  - Authentication is implemented for both web interface and API access.

- __File Management:__

  - Users can upload files through the web interface or API, with uploaded files stored in a specified upload folder on the server.
  - Download and viewing functionalities are available through both the web interface and API.

- __File Listing and Sorting:__

  - The application provides a list of uploaded files along with their modification dates.
  - Users can view the list of files sorted in ascending or descending order by modification date.

- __Last N Files Download API:__

  - An API endpoint allows users to download the last N uploaded files as a zip archive.
  - Users can specify the number of files to include in the archive and provide a custom filename.

- __Markdown File Support:__: Markdown (.md) files can be viewed directly through the web interface, rendered as plain text for easier readability.

- __PWA Offline Access:__

  - The application can be installed as a Progressive Web App (PWA), enabling offline access for users.
  - Users can access the application even in low-connectivity environments.

- __Caching Headers:__: The application sets caching headers to ensure users always access the latest content, preventing browser caching of rendered pages.

- __Enhanced CLI Integration:__: Users can run the server and CLI app using the following commands:
  - `ffs-server` or `ffs server` to start the server.
  - `ffs-cli <cli_command> **kwargs` or `ffs cli <cli_command> **kwargs` to run the CLI app.

- __Python Client Package:__

  - Users can install the Python client package with `pip install flask-file-share`, enabling easy programmatic access to file management functionalities.
  - The package provides a client class for interacting with the API, making it simple to upload, download, and list files.

## Installation and Usage

### Installation

1. Install the package directly from PyPI:

   ```bash
   pip install flask-file-share
   ```

1. Start the Flask development server:

   ```bash
   ffs-server
   ```

1. You can instead clone the repository and install the dependencies:

   ```bash
   # Clone the repository
   git clone https://github.com/hermann-web/simple-file-hosting-with-flask.git
   # Create a virtual environment and activate it
   python3 -m venv env
   source env/bin/activate
   # Install the required dependencies
   pip install -r requirements.txt
   # Start the Flask development server
   python src/flask_file_share/app.py
   ```

1. Access the application by visiting [http://localhost:5000](http://localhost:5000) in your web browser.

### Web Interface Usage

The main page displays a list of shared files.

- To upload a file, click on "Upload a File" and select the file you want to share. The uploaded files will be listed on the main page for download.

- You can rewrite the app's setings using a custom `.env` file in the folder you are running the app from.

- You can acces the interface by running one of the following commands: `ffs server`, `ffs-server`, `python src/flask_file_share/app.py`

### API Usage

You can access the api with the routes `http://localhost:5000/api/*`.

- All available features though the we interface are also available though the api

- You can read the [cli app documentation](./docs/api.md)

### Python Client Usage

You can access the api features through a python script. The module [flask_file_share/client](./src/flask_file_share/client.py) accesses the api using a context manager to handle sessions

Here is a usage example:

   ```python
   import flask_file_share as ffs

   username = "****"  # put your user token here
   password = "****"  # put your user key here
   base_url = "http://localhost:5000"

   # Example usage:
   input_folder = Path("examples/data")
   output_folder = Path("examples/output")
   output_folder.mkdir(exist_ok=True)
   client = ffs.Client(username=username, password=password, base_url=base_url)
   client.login()
   client.upload_file(input_folder / "test_file1.txt")
   client.download_file("noexistant_file", output_folder)
   client.list_files()
   client.upload_file(input_folder / "test_file2.txt")
   client.download_file("test_file2.txt", output_folder)
   client.list_files()
   client.download_last_n_files(5, output_folder)
   client.logout()
   ```

You can read the [python client documentation](./docs/python-client.md)

### CLI Usage

- Run the CLI app using:

   ```bash
   ffs-cli <cli_command> **kwargs
   # or
   ffs cli <cli_command> **kwargs
   # or
   python src/flask_file_share/cli.py
   ```

- The file [flask_file_share/app.py](./src/flask_file_share/cli.py) defines a cli app that uses the python client.

- So, Using your cli, you can also access all features available in the python binding.

- you can read the [cli app documentation](./docs/cli-app.md)

## Deployment Guide

To deploy the File Sharing App, follow these steps:

1. Choose a remote server or cloud provider to host your application. Popular options include AWS, Google Cloud, and Heroku.

2. Set up an instance or virtual machine on your chosen server.

3. Connect to your remote server.

4. Install the required dependencies.

5. Modify the Flask application's configuration to use a production-ready web server.

6. Configure your domain or subdomain to point to the IP address of your remote server.

7. Set up SSL/TLS certificates for secure HTTPS communication.

8. Start the Flask application using the production-ready web server.

9. Verify that your file sharing app is accessible.

10. Monitor the deployed application for errors and performance issues.

Remember to follow best practices for securing your deployed application.

## Todo

1. __Extensions Handling__: Improve MIME Content-type for file opening and raw file parsing. Utilize the extensions map from [github/freelamb/simple_http_server](https://github.com/freelamb/simple_http_server/blob/master/simple_http_server.py#L242) to enhance the versatility of file uploads and downloads.

2. __URL Whitelisting__: Implement URL whitelisting feature to restrict access to specific URLs, enhancing security.

3. __Environment Variable Configuration__: Allow users to set server URLs, domain, and port in the `.env` file for easier configuration management.

4. __CLI Integration with .env File__: Enhance the CLI app to read configuration settings from the `.env` file, providing more flexibility and ease of use.

5. __Server Configuration Override__: Provide an option for users to override server configuration settings from the CLI without relying on the `.env` file.

## Contributors

- Hermann AGOSSOU

## License

This project is licensed under the [MIT License](LICENSE).

## Links

- Repository: <https://github.com/hermann-web/simple-file-hosting-with-flask>
- Issue tracker: <https://github.com/hermann-web/simple-file-hosting-with-flask/issues>
- Inspiration and references:
- [Flask](https://flask.palletsprojects.com/) Web framework for Python.
- [Flask PWA demo](https://github.com/uwi-info3180/flask-pwa)

## Contact

For any inquiries or issues, please contact [this mail address](agossouhermann7@gmail.com).

            

Raw data

            {
    "_id": null,
    "home_page": "https://flask-file-share.readthedocs.io",
    "name": "flask-file-share",
    "maintainer": "Hermann Agossou",
    "docs_url": null,
    "requires_python": "<4.0.0,>=3.8.1",
    "maintainer_email": "agossouhermann7@gmail.com",
    "keywords": "flask, file sharing, web interface, API, CLI",
    "author": "hermann-web",
    "author_email": "hermannagossou6@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/4c/97/2d84d532fb3225fac8fe40ee52e4f7d18528b0467b72fe0db4e34df5e15d/flask_file_share-0.1.2.tar.gz",
    "platform": null,
    "description": "# File Sharing App\n\n__A Flask-based file sharing application with enhanced functionalities.__\n\nThis Flask-based file sharing app provides a user-friendly interface for accessing files uploaded to the server. It allows users to upload, download, and view files through a web interface. Additionally, it provides an API and a CLI App for programmatic access to file management functionalities.\n\n## Features\n\n- __User Authentication:__\n\n  - Users can log in with a username and password to access the file manager's functionalities.\n  - Authentication is implemented for both web interface and API access.\n\n- __File Management:__\n\n  - Users can upload files through the web interface or API, with uploaded files stored in a specified upload folder on the server.\n  - Download and viewing functionalities are available through both the web interface and API.\n\n- __File Listing and Sorting:__\n\n  - The application provides a list of uploaded files along with their modification dates.\n  - Users can view the list of files sorted in ascending or descending order by modification date.\n\n- __Last N Files Download API:__\n\n  - An API endpoint allows users to download the last N uploaded files as a zip archive.\n  - Users can specify the number of files to include in the archive and provide a custom filename.\n\n- __Markdown File Support:__: Markdown (.md) files can be viewed directly through the web interface, rendered as plain text for easier readability.\n\n- __PWA Offline Access:__\n\n  - The application can be installed as a Progressive Web App (PWA), enabling offline access for users.\n  - Users can access the application even in low-connectivity environments.\n\n- __Caching Headers:__: The application sets caching headers to ensure users always access the latest content, preventing browser caching of rendered pages.\n\n- __Enhanced CLI Integration:__: Users can run the server and CLI app using the following commands:\n  - `ffs-server` or `ffs server` to start the server.\n  - `ffs-cli <cli_command> **kwargs` or `ffs cli <cli_command> **kwargs` to run the CLI app.\n\n- __Python Client Package:__\n\n  - Users can install the Python client package with `pip install flask-file-share`, enabling easy programmatic access to file management functionalities.\n  - The package provides a client class for interacting with the API, making it simple to upload, download, and list files.\n\n## Installation and Usage\n\n### Installation\n\n1. Install the package directly from PyPI:\n\n   ```bash\n   pip install flask-file-share\n   ```\n\n1. Start the Flask development server:\n\n   ```bash\n   ffs-server\n   ```\n\n1. You can instead clone the repository and install the dependencies:\n\n   ```bash\n   # Clone the repository\n   git clone https://github.com/hermann-web/simple-file-hosting-with-flask.git\n   # Create a virtual environment and activate it\n   python3 -m venv env\n   source env/bin/activate\n   # Install the required dependencies\n   pip install -r requirements.txt\n   # Start the Flask development server\n   python src/flask_file_share/app.py\n   ```\n\n1. Access the application by visiting [http://localhost:5000](http://localhost:5000) in your web browser.\n\n### Web Interface Usage\n\nThe main page displays a list of shared files.\n\n- To upload a file, click on \"Upload a File\" and select the file you want to share. The uploaded files will be listed on the main page for download.\n\n- You can rewrite the app's setings using a custom `.env` file in the folder you are running the app from.\n\n- You can acces the interface by running one of the following commands: `ffs server`, `ffs-server`, `python src/flask_file_share/app.py`\n\n### API Usage\n\nYou can access the api with the routes `http://localhost:5000/api/*`.\n\n- All available features though the we interface are also available though the api\n\n- You can read the [cli app documentation](./docs/api.md)\n\n### Python Client Usage\n\nYou can access the api features through a python script. The module [flask_file_share/client](./src/flask_file_share/client.py) accesses the api using a context manager to handle sessions\n\nHere is a usage example:\n\n   ```python\n   import flask_file_share as ffs\n\n   username = \"****\"  # put your user token here\n   password = \"****\"  # put your user key here\n   base_url = \"http://localhost:5000\"\n\n   # Example usage:\n   input_folder = Path(\"examples/data\")\n   output_folder = Path(\"examples/output\")\n   output_folder.mkdir(exist_ok=True)\n   client = ffs.Client(username=username, password=password, base_url=base_url)\n   client.login()\n   client.upload_file(input_folder / \"test_file1.txt\")\n   client.download_file(\"noexistant_file\", output_folder)\n   client.list_files()\n   client.upload_file(input_folder / \"test_file2.txt\")\n   client.download_file(\"test_file2.txt\", output_folder)\n   client.list_files()\n   client.download_last_n_files(5, output_folder)\n   client.logout()\n   ```\n\nYou can read the [python client documentation](./docs/python-client.md)\n\n### CLI Usage\n\n- Run the CLI app using:\n\n   ```bash\n   ffs-cli <cli_command> **kwargs\n   # or\n   ffs cli <cli_command> **kwargs\n   # or\n   python src/flask_file_share/cli.py\n   ```\n\n- The file [flask_file_share/app.py](./src/flask_file_share/cli.py) defines a cli app that uses the python client.\n\n- So, Using your cli, you can also access all features available in the python binding.\n\n- you can read the [cli app documentation](./docs/cli-app.md)\n\n## Deployment Guide\n\nTo deploy the File Sharing App, follow these steps:\n\n1. Choose a remote server or cloud provider to host your application. Popular options include AWS, Google Cloud, and Heroku.\n\n2. Set up an instance or virtual machine on your chosen server.\n\n3. Connect to your remote server.\n\n4. Install the required dependencies.\n\n5. Modify the Flask application's configuration to use a production-ready web server.\n\n6. Configure your domain or subdomain to point to the IP address of your remote server.\n\n7. Set up SSL/TLS certificates for secure HTTPS communication.\n\n8. Start the Flask application using the production-ready web server.\n\n9. Verify that your file sharing app is accessible.\n\n10. Monitor the deployed application for errors and performance issues.\n\nRemember to follow best practices for securing your deployed application.\n\n## Todo\n\n1. __Extensions Handling__: Improve MIME Content-type for file opening and raw file parsing. Utilize the extensions map from [github/freelamb/simple_http_server](https://github.com/freelamb/simple_http_server/blob/master/simple_http_server.py#L242) to enhance the versatility of file uploads and downloads.\n\n2. __URL Whitelisting__: Implement URL whitelisting feature to restrict access to specific URLs, enhancing security.\n\n3. __Environment Variable Configuration__: Allow users to set server URLs, domain, and port in the `.env` file for easier configuration management.\n\n4. __CLI Integration with .env File__: Enhance the CLI app to read configuration settings from the `.env` file, providing more flexibility and ease of use.\n\n5. __Server Configuration Override__: Provide an option for users to override server configuration settings from the CLI without relying on the `.env` file.\n\n## Contributors\n\n- Hermann AGOSSOU\n\n## License\n\nThis project is licensed under the [MIT License](LICENSE).\n\n## Links\n\n- Repository: <https://github.com/hermann-web/simple-file-hosting-with-flask>\n- Issue tracker: <https://github.com/hermann-web/simple-file-hosting-with-flask/issues>\n- Inspiration and references:\n- [Flask](https://flask.palletsprojects.com/) Web framework for Python.\n- [Flask PWA demo](https://github.com/uwi-info3180/flask-pwa)\n\n## Contact\n\nFor any inquiries or issues, please contact [this mail address](agossouhermann7@gmail.com).\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Flask-based file sharing with web interface, API, and CLI app",
    "version": "0.1.2",
    "project_urls": {
        "Documentation": "https://flask-file-share.readthedocs.io",
        "Homepage": "https://flask-file-share.readthedocs.io",
        "Repository": "https://github.com/Hermann-web/simple-file-hosting-with-flask"
    },
    "split_keywords": [
        "flask",
        " file sharing",
        " web interface",
        " api",
        " cli"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "f4574047995da639924521c9406a398cdfb216030e290b9e7c35d38439988ec1",
                "md5": "a6f1b41b514aa3a1065002734862767b",
                "sha256": "0517a23e94e4032d450822b07ae0d73edf9a5274e35fcfa982f23e0546616487"
            },
            "downloads": -1,
            "filename": "flask_file_share-0.1.2-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "a6f1b41b514aa3a1065002734862767b",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "<4.0.0,>=3.8.1",
            "size": 9143027,
            "upload_time": "2024-04-28T16:54:47",
            "upload_time_iso_8601": "2024-04-28T16:54:47.014550Z",
            "url": "https://files.pythonhosted.org/packages/f4/57/4047995da639924521c9406a398cdfb216030e290b9e7c35d38439988ec1/flask_file_share-0.1.2-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "4c972d84d532fb3225fac8fe40ee52e4f7d18528b0467b72fe0db4e34df5e15d",
                "md5": "9411fbaa9c4285f8c000c8e416109699",
                "sha256": "6be6985572367e94e537d5becb15decd44961a9ac5f9532ce7298d70262491df"
            },
            "downloads": -1,
            "filename": "flask_file_share-0.1.2.tar.gz",
            "has_sig": false,
            "md5_digest": "9411fbaa9c4285f8c000c8e416109699",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "<4.0.0,>=3.8.1",
            "size": 9135034,
            "upload_time": "2024-04-28T16:54:53",
            "upload_time_iso_8601": "2024-04-28T16:54:53.072885Z",
            "url": "https://files.pythonhosted.org/packages/4c/97/2d84d532fb3225fac8fe40ee52e4f7d18528b0467b72fe0db4e34df5e15d/flask_file_share-0.1.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-04-28 16:54:53",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "Hermann-web",
    "github_project": "simple-file-hosting-with-flask",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "requirements": [],
    "lcname": "flask-file-share"
}
        
Elapsed time: 0.23931s