This repository contains a FastAPI application designed to generate PDFs from HTML and CSS content. It's packaged with Docker and orchestrated using Docker Compose, simplifying development and deployment processes. Openapi spec at /openapi.json
- FastAPI: A modern, fast (high-performance) web framework for building APIs with Python 3.7+ based on standard Python type hints.
- Docker: Containerization of the application ensuring consistency across various development and deployment environments.
- Docker Compose: Simplifies the setup of local development and services needed to run the application.
Before you can run this application, you'll need:
These instructions will cover usage information and for the docker container
Clone the repository to your local machine:
git clone https://github.com/yourusername/your-repository-name.git
cd your-repository-name
To build and run the application in a Docker container, execute:
docker-compose up --build
This command builds the Docker image if it hasn't been built and starts the containers specified in the docker-compose.yml
file.
Once the application is running, you can access:
- The API at: http://localhost:8000
- Swagger UI Documentation at: http://localhost:8000/docs
- ReDoc Documentation at: http://localhost:8000/redoc
POST /create
: Endpoint to create a PDF from HTML and CSS.POST /convert_urls
: Endpoint to convert given URLs into PDFs.GET /
: Serves theindex.html
file (not shown in API docs).
Configure the following environment variables before starting the application:
API_KEY
: The API key for accessing the secured endpoints. (Optional)BASE_URL
: The base URL for the application. Defaults tohttp://localhost
.
If you need to add new Python packages:
- Add the package to the
requirements.txt
file. - Rebuild the Docker image:
docker-compose up --build
Run tests directly within your Docker container:
docker-compose exec web pytest
To deploy this application, use the provided Dockerfile
and docker-compose.yml
files to manage and scale the application across different environments.