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.
-
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.
-
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.
-
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.
-
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.
-
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. -
General Folder: FSFS now includes a "GENERAL_FOLDER" for files with extensions not covered by existing categories.
-
Delete: delete specific file using the filename as the value for the
delete
endpoint make it easier to delete unwanted file.
Setting up FSFS is a straightforward process. Follow these steps:
-
Clone the Repository:
git clone https://github.com/1999AZZAR/Flask-Simple-File-Server.git cd Flask-Simple-File-Server
-
Install Dependencies:
pip install -r requirements.txt
-
Run the Application:
cd code python the_server.py
Access the server at http://localhost:2500 and here for more detailed instructions.
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.
Endpoint: /upload
Method: POST
Parameters:
file
: The file to be uploaded- example
Endpoint: /download
Method: GET
Parameters:
filename
: The name of the file to be downloadedfileformat
: The file format for bulk downloadextension
: The file extension for bulk downloadall
: Download all files- usage example
/download?fileformat=Image
will download all image files. - code example
Endpoint: /list
Method: GET
Returns: JSON array containing details of all uploaded files
- 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.
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".
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 fileextension
: File extensioncategory
: File category (e.g., Image, Video)upload_time
: Timestamp of when the file was uploaded
Files are intelligently categorized into the following folders based on their extensions:
other_files
: Miscellaneous filesxml_files
: XML-related filesimg_files
: Image filesvideo_files
: Video filesaudio_files
: Audio filesdocument_files
: Document filescompressed_files
: Compressed filesnull_files
: Files with no recognizable extensiongeneral_files
: Files with unknown extensions
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.
FSFS is licensed under the MIT License. Your usage and contributions are subject to the terms specified in the license.