A Flask-based REST API for sentiment analysis using the BERT model.
- Create a virtual environment:
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate- Install dependencies:
pip install -r requirements.txt- Create a
.envfile (optional):
FLASK_DEBUG=False
FLASK_HOST=0.0.0.0
FLASK_PORT=5000
python app.pyThe API will be available at http://localhost:5000
- Health check endpoint
- Returns: "Hello, World!"
- Test endpoint
- Returns:
{"message": "Hello, API!"}
- Sentiment analysis endpoint
- Request body:
{
"data": {
"text": "Your text here"
}
}- Returns: Sentiment analysis results
.
├── app.py # Main application entry point
├── config.py # Configuration settings
├── requirements.txt # Project dependencies
├── routes/ # API routes
│ └── sentiment_routes.py
└── services/ # Business logic
└── sentiment_service.py