A collection of free open source APIs that just work.
git clone https://github.com/Danscot/Danapi
cd Danapipython3 -m venv env
source ./env/bin/activate
pip install -r requirements.txtCreate a .env file:
nano .envExample content:
DEBUG=True
SECRET_KEY='your_secret_key'
EMAIL_HOST='smtp.example.com'
EMAIL_HOST_USER='your_email@example.com'
EMAIL_HOST_PASSWORD='your_email_password'
DEFAULT_FROM_EMAIL='your_email@example.com'
YOUTUBE_API='your_youtube_api_key'
mkdir static
python3 manage.py collectstaticEdit allowed hosts in ./Danapi/settings.py:
ALLOWED_HOSTS = ['yourdomain.com', 'www.yourdomain.com']sudo nano /etc/systemd/system/danapi.servicePaste:
[Unit]
Description=Gunicorn for Danapi
After=network.target
[Service]
User=www-data
Group=www-data
WorkingDirectory=/home/ubuntu/Danapi
Environment="PATH=/home/ubuntu/Danapi/env/bin"
RuntimeDirectory=danapi
RuntimeDirectoryMode=755
ExecStart=/home/ubuntu/Danapi/env/bin/gunicorn \
--workers 3 \
--bind unix:/run/danapi/danapi.sock \
Danapi.wsgi:application
[Install]
WantedBy=multi-user.targetReload and start service:
sudo systemctl daemon-reload
sudo systemctl restart danapi
sudo systemctl status danapisudo nano /etc/nginx/sites-available/danapiExample config:
server {
listen 80;
server_name yourdomain.com www.yourdomain.com;
location /static/ {
alias /home/ubuntu/Danapi/staticfiles/;
}
location / {
proxy_pass http://unix:/run/danapi/danapi.sock;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}Enable site and reload Nginx:
sudo ln -s /etc/nginx/sites-available/danapi /etc/nginx/sites-enabled/
sudo nginx -t
sudo systemctl reload nginxsudo certbot --nginx -d yourdomain.com -d www.yourdomain.com- Replace
/home/ubuntuwith the correct path based on your system. - This guide assumes a VPS running Ubuntu with Nginx and systemd.
- Make sure all paths and domain names match your server configuration.