Rest-API for german sentiment analysis of an input text.
Create a new venv (virtual environment):
python3 -m venv .venv
Activate new environment:
For Mac/Linux:
source .venv/bin/activate
For Windows:
source .venv/Scripts/activate
Install packages:
pip install -r requirements.txt
Download the model:
python -m app.save_model
API_KEY=CHANGE_ME uvicorn app.main:app --reload
The server is running on http://localhost:8000.You can change the API_KEY
if you like. Swagger documentation can be accessed at http://localhost:8000/docs.
To send a request via your terminal, paste & run the following command:
curl -X POST -H 'Content-type: application/json' -H 'X-API-Key: CHANGE_ME' --data '{"text":"Hello, World!"}' http://localhost:8000
docker build -t sentiment-api-de .
Run the Docker Image with:
docker run -d --rm -p 8000:80 --env API_KEY=CHANGE_ME --name sentiment-api-de sentiment-api-de
You can now access the api at http://localhost:8000. Swagger documentation are available at http://localhost:8000/docs.
To view the logs of the container run:
docker logs sentiment-api-de
To stop the container run:
docker stop sentiment-api-de
You can spin up the setup using docker compose and benefit e.g. from automatic server restarts. Before running the setup, please change the environment variable in the docker-compose.yml
file. Then run:
docker compose up -d
To stop the setup you can run
docker compopse down
To rebuild the docker image run
docker compose build
Logs can be accessed with
docker compose logs