Skip to content

stackOcean-official/sentiment-api-de

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

sentiment-api-de

Rest-API for german sentiment analysis of an input text.

How to setup

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

Run the server

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

How to build & run the Docker Image

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

How to use docker compose

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

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published