Coder Social home page Coder Social logo

1999azzar / flask-simple-file-server Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 113 KB

FSFS is a lightweight Flask-based file server, efficient and user-friendly solution for handling diverse file formats seamlessly.

License: MIT License

Python 100.00%
filemanagement filesystem flask-application python api

flask-simple-file-server's Introduction

Flask Simple File Server (FSFS)

Table of Contents

Introduction

Flask Simple File Server (FSFS) is a robust and user(admin)-friendly data application developed with Flask. Its primary purpose is to facilitate seamless file management, offering features like file upload, download, and categorization. Built on top of Flask, FSFS ensures a lightweight and efficient solution for organizing and accessing files.

Features

  1. File Upload and Categorization: Users can effortlessly upload files through the intuitive web interface. FSFS automatically categorizes files based on their extensions, making it easy to organize and locate them.

  2. File Download:

    • standard: Downloading files is straightforward. Users can retrieve files by specifying the filename, and FSFS provides a direct download link for quick access.
    • enhanced: download endpoints for better user experience, supporting specific files, file formats, extensions, and bulk downloads.
  3. File Listing: FSFS maintains a detailed list of all uploaded files, including essential information such as filename, extension, category, and upload timestamp. This feature enhances visibility and allows users to review their uploaded content easily.

  4. File Categorization: Uploaded files are intelligently organized into distinct folders according to their file types. This systematic categorization includes folders for images, videos, audio files, documents, compressed files, XML-related files, and a miscellaneous folder for unrecognized file types.

  5. SQLite Database Integration: FSFS utilizes an SQLite database (files.db) to store and manage file metadata. The database ensures data persistence and enables efficient retrieval of file information.

  6. General Folder: FSFS now includes a "GENERAL_FOLDER" for files with extensions not covered by existing categories.

  7. Delete: delete specific file using the filename as the value for the delete endpoint make it easier to delete unwanted file.

Installation

Setting up FSFS is a straightforward process. Follow these steps:

  1. Clone the Repository:

    git clone https://github.com/1999AZZAR/Flask-Simple-File-Server.git
    cd Flask-Simple-File-Server
  2. Install Dependencies:

    pip install -r requirements.txt
  3. Run the Application:

    cd code
    python the_server.py

    Access the server at http://localhost:2500 and here for more detailed instructions.

Usage

FSFS offers a user-friendly experience for managing files. Users can utilize the provided API endpoints to interact with the file server. Refer to the API Endpoints section for detailed information.

API Endpoints

1. Upload File

Endpoint: /upload
Method: POST
Parameters:

  • file: The file to be uploaded
  • example

2. Download File

Endpoint: /download
Method: GET
Parameters:

  • filename: The name of the file to be downloaded
  • fileformat: The file format for bulk download
  • extension: The file extension for bulk download
  • all: Download all files
  • usage example /download?fileformat=Image will download all image files.
  • code example

3. List Files

Endpoint: /list
Method: GET
Returns: JSON array containing details of all uploaded files

4. List Files with Specific File Format or Extension

  • To list files of a specific file format, use /list?fileformat=<your_file_format>
  • To list files with a specific extension, use /list?extension=<your_extension>

For example:

  • /list?fileformat=Image will list all image files.
  • /list?extension=.pdf will list all PDF files.

5. Delete File

Endpoint: /delete/<filename>
Method: DELETE
Parameters:

  • filename: The name of the file to be deleted

Usage example: /delete/myfile.txt will delete the file named "myfile.txt".

Database Structure

FSFS employs an SQLite database (files.db) with a table named files to store file information. The table structure is as follows:

  • filename: Name of the uploaded file
  • extension: File extension
  • category: File category (e.g., Image, Video)
  • upload_time: Timestamp of when the file was uploaded

File Categories

Files are intelligently categorized into the following folders based on their extensions:

  • other_files: Miscellaneous files
  • xml_files: XML-related files
  • img_files: Image files
  • video_files: Video files
  • audio_files: Audio files
  • document_files: Document files
  • compressed_files: Compressed files
  • null_files: Files with no recognizable extension
  • general_files: Files with unknown extensions

Flowchart

Flowchart

Contributing

Contributions to FSFS are highly encouraged. Whether it's bug fixes, feature enhancements, or feedback, your input is valuable. Feel free to open issues or submit pull requests.

License

FSFS is licensed under the MIT License. Your usage and contributions are subject to the terms specified in the license.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.