Skip to main content

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:

  1. GET /: Health check endpoint

    curl -X GET http://localhost:8000/
    
  2. 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"}'
    
  3. 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"}'
    
  4. 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"}'
    
  5. 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"}'
    
  6. 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"}'
    
  7. 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!"}'
    
  8. 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"}'
    
  9. 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"}'
    
  10. 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"}'
    
  11. 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:

  1. server section:
    • port: The port number on which the API server will run. Default is 8000.
  2. auth section:
    • username: The username for basic authentication.
    • password: The password for basic authentication.
  3. 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:

Javer Valino

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.

Metadata

Release files for folder-manager-api 1.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for folder-manager-api 1.0.1
File Size Uploaded
folder_manager_api-1.0.1.tar.gz 5.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for folder-manager-api 1.0.1
File Interpreter ABI Platform
folder_manager_api-1.0.1-py3-none-any.whl Python 3 none any Details

Total release size: 10.9 kB

Release files / folder_manager_api-1.0.1.tar.gz

Download URL folder_manager_api-1.0.1.tar.gz
Size 5.0 kB
Tags Source
SHA-256 checksum
How to use checksums
3bfa9b64929df4232b761078934d748d7900a5a429c39a9d9ddcae602f1d5ab7
BLAKE2b-256 checksum
How to use checksums
2aca768f84b7787d88b45f88c93d37ecf93157c5783e7529b0b098022d341a1d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.12.4

Release files / folder_manager_api-1.0.1-py3-none-any.whl

Download URL folder_manager_api-1.0.1-py3-none-any.whl
Size 5.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
cb14ccbda2845d82c9e529dc102f18d050b29b2ea7d61d0690f5e1cfbe1e1c7d
BLAKE2b-256 checksum
How to use checksums
3c218f8191e906ed696c0d8f86922ec14966641a9986d51bb5d6a081add4fb61
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.12.4

Release history Release notifications | RSS feed

This release

1.0.1 This release

2 release files

1.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page