Best Flask open-source libraries and packages

Simple file hosting with flask

Flask-based file sharing app providing web and API access for seamless file uploads, downloads, and sharing. Includes a CLI for easy API interaction. It can be easily hosted on a server
Updated 4 months ago

File Sharing App

A simple Flask application for sharing files.

This Flask-based file manager provides a user-friendly interface for managing 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 both for web interface access and API access.

File Management

  • Users can upload files to the server through the web interface or API.
  • Uploaded files are stored in a specified upload folder on the server.
  • File 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

  • The application supports viewing Markdown (.md) files directly through the web interface.
  • Markdown files are rendered as plain text for easier readability.

Caching Headers

  • The application sets caching headers to instruct the browser not to cache the rendered pages, ensuring that users always access the latest content.

Progressive Web App (PWA) Setup

  • The application is configured as a Progressive Web App (PWA), allowing users to install it on their devices and use it like a native app.
  • The PWA setup enables offline access, push notifications, and improved performance.

Installation and Setup

Prerequisites

  • Python 3.x
  • Flask
  • Python packages specified in requirements.txt

Installation

  1. Clone the repository:

    git clone https://github.com/hermann-web/simple-file-hosting-with-flask.git
  2. Create a virtual environment and activate it:

    python3 -m venv env
    source env/bin/activate
  3. Install the required dependencies:

    pip install -r requirements.txt
  4. Start the Flask development server:

    python src/app.py
  5. Access the application by visiting http://localhost:5000 in your web browser.

Usage

access the flask web

  • 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.

access the app through an api

access the app's api with a cli app

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 to enhance the versatility of file uploads and downloads.

    • Inspiration from Other Repositories: The simple_http_server repository as an interesting resource for download handlers.
  2. CLI App Enhancement: Investigate the possibility of implementing bash completion for the CLI app to streamline command-line interactions. Refer to resources and discussions on implementing bash completion for Python applications, such as those found here, to improve usability and efficiency.

Contributors

  • Hermann AGOSSOU

License

This project is licensed under the MIT License.

Links

Contact

For any inquiries or issues, please contact this mail address.

Tags cli