A lightweight web application for managing text files with a RESTful API and web interface. Built with FastAPI and React (using Vite as the bundler).
- Web-based file management interface
- RESTful API for file operations
- File preview functionality with customizable templates
- Search and filter capabilities
- Responsive design
.
├── main.py # FastAPI application
├── requirements.txt # Python dependencies
├── storage/ # Directory for storing text files (created automatically)
├── templates/ # HTML templates for file preview
├── frontend/ # React frontend application (using Vite)
│ ├── dist/ # Built frontend files
│ ├── src/ # Source code
│ └── package.json # Node.js dependencies
└── README.md # This file
GET /api/files/- List all files (with optional search query)GET /api/files/{filepath}- Read a filePOST /api/files/{filepath}- Create a new filePUT /api/files/{filepath}- Update an existing fileDELETE /api/files/{filepath}- Delete a file
GET /api/preview/{filepath}?template={template}- Preview a file using a specific HTML template
GET /- Main web application
- Python 3.8+
- Node.js (for frontend development)
- Clone the repository
- Install Python dependencies:
pip install -r requirements.txt
- Run the application:
uvicorn main:app --reload
The frontend is built with React and Vite:
- Navigate to the frontend directory:
cd frontend - Install dependencies:
npm install
- Start the development server:
npm run dev
- Build for production:
npm run build
The application includes a multi-stage Dockerfile that:
- Builds the React frontend using Node.js
- Serves the FastAPI backend with the built frontend
To run with Docker:
docker build -t poemata-editor .
docker run -p 8000:8000 poemata-editorOr use docker-compose:
docker-compose up- Access the web interface at
http://localhost:8000 - Use the API endpoints to manage files programmatically
- Preview files using the
/api/previewendpoint with appropriate templates
Text files should follow this structure:
- First line: Title
- Middle lines: Content
- Last line: Footer/Author information
HTML templates in the templates/ directory can be used to preview files with different styling. The template receives:
title: First line of the filecontent: Array of middle linesfooter: Last line of the file
- Fork the repository
- Create a feature branch
- Commit your changes
- Push to the branch
- Create a pull request
This project is licensed under the MIT License.