This API is an integral component of the AbbyBot project, providing comprehensive data services related to Discord bot servers, users, and bot-specific information.
requirements.txt
Make sure you have all the necessary packages installed by running:
pip install -r requirements.txt
The environment variables required for the API are now included in the .env.example file. You can use this file as a template to create your own .env file.
# Copy the example file to create your .env file
cp .env.example .envMake sure to update the values in the .env file with
your specific configuration.
- Clone the repository and navigate to the folder.
- Set up your
.envfile with the appropriate values.
- Run the Flask application (development mode):
python main.py
The API will be available at
http://127.0.0.1:5002/.
For greater ease, this API can be deployed using Docker along with Docker Compose.
This Docker setup is specifically designed for production, not for development. It will expose a port on the server, specifically 5002.
As mentioned, this is for production, so the first step would be to clone the repository on your server in a folder appropriate for the HTTP server you are using, such as Apache or Nginx.
Steps to build and run the container:
Make sure you have completed the previous step of creating the
.envfile based on.env.exampleand filling it with your actual variables.Execute the following command:
sudo docker compose build
The blue whale 🐳 will start building the API container, copying all the files, including the
.env. For this reason, the.envfile must be created before starting the Docker build process.If everything went well, the terminal will display messages like the following:
[+] Building 1/1
✔ web Built If you see "built," it indicates that the build was successful.
- To start the Docker container, simply run:
sudo docker compose up -d
Note: We add the
-dflag to run the container in the background on your server.
- If everything went well, the terminal will return to showing your username as usual. The next step will be to set up a reverse proxy using your HTTP server, such as Apache or Nginx.
To set up a reverse proxy for port 5002, you can use either Apache or Nginx. Below are examples for both:
- Enable the required modules:
sudo a2enmod proxy proxy_http
sudo systemctl restart apache2 #or httpd- Add the following to your Apache configuration file:
<VirtualHost*:80>
ServerName yourdomain.com
ProxyPass / http://127.0.0.1:5002/
ProxyPassReverse / http://127.0.0.1:5002/
</VirtualHost>- Restart Apache:
sudo systemctl restart apache2 #or httpd- Add the following to your Nginx configuration file:
server{listen80;server_name yourdomain.com;location / {proxy_passhttp://127.0.0.1:5002;proxy_set_header Host $host;proxy_set_header X-Real-IP $remote_addr;}}- Test and reload Nginx:
sudo nginx -t
sudo systemctl reload nginxReplace yourdomain.com with your actual domain name.
- AbbyBotProject team
