A lightweight REST API built with Flask that provides text translation functionality via HTTP endpoints.
Designed as a minimal microservice, this project allows applications to send text and receive translated content in response. It is simple, deployable, and easy to integrate into frontend or backend systems.
- RESTful translation endpoint
- Lightweight Flask architecture
- JSON-based request/response
- Easy local setup
- Procfile support for cloud deployment
- Ready for integration with frontend or external services
- Python 3.9+
- pip
- Clone the repository:
git clone <your-repository-url>
cd flask-main- Create a virtual environment:
python -m venv venv
source venv/bin/activate # macOS/Linux
# venv\Scripts\activate # Windows- Install dependencies:
pip install -r requirements.txtpython main.pyThe API will start at:
http://localhost:5000
POST /translate
Content-Type: application/json
{
"text": "Hello world",
"source_language": "en",
"target_language": "pt"
}{
"translated_text": "Olá mundo"
}export FLASK_ENV=development
export FLASK_APP=main.py
flask runThis project includes a Procfile, allowing deployment on:
- Heroku
- Railway
- Render
- Other Procfile-compatible PaaS platforms
Example deployment:
git push heroku mainflask-main/
│
├── main.py # Application entry point
├── requirements.txt # Dependencies
├── Procfile # Deployment configuration
└── .gitignore
- Store API keys using environment variables
- Do not commit secrets
- Use a production WSGI server (e.g., Gunicorn) for deployment