A FastAPI wrapper for the folder_manager package, providing a RESTful API for managing folders and files.
Project description
Folder Manager API
folder_manager_api is a FastAPI wrapper for the folder_manager package, providing a RESTful API for managing folders and files.
Features:
- Create and delete folders
- List files in a folder
- Count files in a folder
- Create and delete files
- Check if a folder or file exists
- List and count files with specific extensions
- Basic authentication
- Logging functionality
Installation:
You can install folder_manager_api using pip:
pip install folder_manager_api
Usage:
To run the API server:
folder_manager_api
or
python -m folder_manager_api
This will start the server on http://localhost:8000.
API Endpoints and Sample Requests:
-
GET /: Health check endpoint
curl -X GET http://localhost:8000/
-
POST /create_folder/: Create a new folder
curl -X POST http://localhost:8000/create_folder/ -H "Content-Type: application/json" -d '{"path": "/path/to/new/folder"}'
-
POST /list_files/: List files in a folder
curl -X POST http://localhost:8000/list_files/ -H "Content-Type: application/json" -d '{"path": "/path/to/folder"}'
-
POST /list_files_with_extension/: List files with a specific extension
curl -X POST http://localhost:8000/list_files_with_extension/ -H "Content-Type: application/json" -d '{"path": "/path/to/folder", "extension": ".txt"}'
-
POST /count_files/: Count files in a folder
curl -X POST http://localhost:8000/count_files/ -H "Content-Type: application/json" -d '{"path": "/path/to/folder"}'
-
POST /count_files_with_extension/: Count files with a specific extension
curl -X POST http://localhost:8000/count_files_with_extension/ -H "Content-Type: application/json" -d '{"path": "/path/to/folder", "extension": ".txt"}'
-
POST /create_file/: Create a new file
curl -X POST http://localhost:8000/create_file/ -H "Content-Type: application/json" -d '{"path": "/path/to/folder", "file_name": "newfile.txt", "content": "Hello, World!"}'
-
POST /delete_file/: Delete a file
curl -X POST http://localhost:8000/delete_file/ -H "Content-Type: application/json" -d '{"path": "/path/to/folder", "file_name": "file_to_delete.txt"}'
-
POST /delete_folder/: Delete a folder
curl -X POST http://localhost:8000/delete_folder/ -H "Content-Type: application/json" -d '{"path": "/path/to/folder/to/delete"}'
-
POST /folder_exists/: Check if a folder exists
curl -X POST http://localhost:8000/folder_exists/ -H "Content-Type: application/json" -d '{"path": "/path/to/check"}'
-
POST /file_exists/: Check if a file exists
curl -X POST http://localhost:8000/file_exists/ -H "Content-Type: application/json" -d '{"path": "/path/to/folder", "file_name": "file_to_check.txt"}'
Note: All endpoints require basic authentication. Add -u username:password to your curl commands or use appropriate authentication in your HTTP client.
Configuration:
The API can be configured using a folder_manager_api.config file. If not present, a default configuration will be created.
Sample configuration file (folder_manager_api.config):
[server]
port = 8000
[auth]
username = admin
password = password
[logging]
log_size = 1073741824
Configuration details:
- server section:
- port: The port number on which the API server will run. Default is 8000.
- auth section:
- username: The username for basic authentication.
- password: The password for basic authentication.
- logging section:
- log_size: Maximum size of the log file in bytes before it rotates. Default is 1073741824 (1GB).
You can modify these values to customize the API's behavior. If the configuration file is not present when the API starts, it will create a default one with these values.
Logging:
The API logs all requests and responses to a file named folder_manager_api.log. The log file uses a rotating file handler, which means it will create new log files and archive old ones when the file size limit (specified in log_size) is reached.
Dependencies:
- fastapi
- uvicorn
- pydantic
- folder_manager
License:
This project is licensed under the MIT License.
Author:
Links:
GitHub: https://github.com/phintegrator/folder_manager_api
Contributing:
Contributions are welcome! Please feel free to submit a Pull Request.
Support:
If you encounter any problems or have any questions, please open an issue on the GitHub repository.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file folder_manager_api-1.0.0.tar.gz
.
File metadata
- Download URL: folder_manager_api-1.0.0.tar.gz
- Upload date:
- Size: 5.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f6bcdafdef854b938b855a5faf6e34a946a6f47e7892acc2c45376ce479fb472 |
|
MD5 | 452f2be0b0a92b4cc0bdac8fb212ba75 |
|
BLAKE2b-256 | 3a625d44181fd12995189d0e6bfeeccfaf84716780973bf588434cde0c586f25 |
File details
Details for the file folder_manager_api-1.0.0-py3-none-any.whl
.
File metadata
- Download URL: folder_manager_api-1.0.0-py3-none-any.whl
- Upload date:
- Size: 5.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d554d6dbbf766e1f06829b5ebdf336112f02ead6c71e9296374974f6c0af3f92 |
|
MD5 | 31cf2d4f2f00b3c72a4c005518e183fe |
|
BLAKE2b-256 | e3571765d8aa8fd16f42ee732ad8bf67ec644c0f0ffc27b46ab002f965bfe8c7 |