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.
- 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.
- 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.
- 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.
- 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.
- The application supports viewing Markdown (.md) files directly through the web interface.
- Markdown files are rendered as plain text for easier readability.
- The application sets caching headers to instruct the browser not to cache the rendered pages, ensuring that users always access the latest content.
- 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.
- Python 3.x
- Flask
- Python packages specified in
requirements.txt
-
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/app.py
-
Access the application by visiting http://localhost:5000 in your web browser.
- 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 access the api with the routes
http://localhost:5000/api/*
- The file cli_app/file_sharing_client to access the api along with a context manager to handle sessions
- you can read the api documentation
- The file cli_app/sharefile.py provide a cli app to access the api context manager
- Using your cli, you can get list, upload and download files. The api will be called behind the hood by cli_app/file_sharing_client
- you can read the api documentation
To deploy the File Sharing App, follow these steps:
-
Choose a remote server or cloud provider to host your application. Popular options include AWS, Google Cloud, and Heroku.
-
Set up an instance or virtual machine on your chosen server.
-
Connect to your remote server.
-
Install the required dependencies.
-
Modify the Flask application's configuration to use a production-ready web server.
-
Configure your domain or subdomain to point to the IP address of your remote server.
-
Set up SSL/TLS certificates for secure HTTPS communication.
-
Start the Flask application using the production-ready web server.
-
Verify that your file sharing app is accessible.
-
Monitor the deployed application for errors and performance issues.
Remember to follow best practices for securing your deployed application.
-
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.
-
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.
- Hermann AGOSSOU
This project is licensed under the MIT License.
- 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 Web framework for Python.
- Flask PWA demo
For any inquiries or issues, please contact this mail address.