- Clone the repository.
- Customize the
server.conf
file for Nginx, or remove it if not needed. - Execute the
start.sh
script to automate the setup of a virtual environment and install dependencies.
This Flask-based web application serves as a powerful API for translating \frac{3}{2}
translates to ((3)/(2))
, streamlining input for popular calculator interfaces.
-
Flask Framework: Utilizes Flask to build an Aaynchronous and lightweight web application architecture, designed to provide a REST API with low-latency interactions.
-
Advanced Logging Mechanism: Implements a dual logging system with separate log files for general and error logs, enhancing traceability and debugging. Logs include timestamps and performance statistic for improved context.
-
Automated Dependency Management: The
start.sh
script seamlessly manages the creation of a virtual environment and installation of required packages fromrequirements.txt
. It intelligently prompts for missing components like Python andpip
, ensuring a smooth setup process. -
Multi-Endpoint Architecture: Supports both browser and HTTP POST requests, with dedicated endpoints for each. The
/translate
endpoint processes JSON payloads for LaTeX translations and logs performance metrics, while also serving a user-friendly translation page for interactive use. -
Parallel Processing: Uses Gunicorn to run multiple worker processes, allowing for concurrent handling of translation requests and optimizing response times under load.
- GitHub Actions automatically runs unit tests whenever changes are pushed to GitHub. This ensures that the codebase remains functional and reliable while quickly identifying any issues introduced by recent changes. The most recent status of those tests are right below.
This API uses the REST (Representational State Transfer) architecture for handling LaTeX translation requests through structured HTTP methods like POST and OPTIONS.
- Translation Endpoint (
/translate
):- POST: Accepts LaTeX formulas from the associated Chrome Extension and provides customization options for the output. It logs execution time and the original request for performance tracking.
- OPTIONS: Manages CORS preflight requests, ensuring proper permissions before processing more complex interactions.
- Index Route (
/
): Serves the main HTML interface for user interactions, providing a front-end page for accessing the service.
The application includes error handling to provide helpful messages when issues arise, along with sorted logging to capture details for later review, contributing to a smooth user experience.
Nginx functions as a reverse proxy, routing incoming traffic to the Flask application. The Flask app processes requests through the local translateLatex
module and returns complete responses, ensuring efficient resource utilization and scalability.