Jahongir-Qurbonov / TodoAPI

Todo API

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

TodoAPI

Todo loyihasi uchun djangoda yozilgan rest api

Mos keladigan python versiyalari

Python [3.6, 3.7, 3.8, 3.9 va 3.10]. Tavfsiya qilinadigan versiya: 3.10

Virtual muhitni yaratish

python -m venv venv

Virtual muhitni aktivlashtirish

Har safar terminalni qayta ochganda virtual muhitni aktivlashtirish kerak

Linux

source venv/bin/activate

Windows

cmd.exe

venv\Scripts\activate.bat

PowerShell

venv\Scripts\activate.ps1

O'rnatish

Kerakli paketlarni o'rnatish uchun pip paket menejeridan foydalaning.

pip install -r requirements.txt

Database yaratish va ilovalarni migratsiyalash

python manage.py migrate

Automatik konfiguratsiyani ishga tushirish

python manage.py runscript -v3 auto_configure

Gunicorn setup

nano /etc/systemd/system/gunicorn_TodoAPI.socket
[Unit]
Description=TodoAPI gunicorn socket
[Socket]
ListenStream=/run/gunicorn_TodoAPI.sock
[Install]
WantedBy=sockets.target

and

nano /etc/systemd/system/gunicorn_TodoAPI.service
[Unit]
Description=gunicorn daemon
Requires=gunicorn_TodoAPI.socket
After=network.target
[Service]
User=root
Group=www-data
WorkingDirectory=/home/ecs-user/TodoAPI
ExecStart=/home/ecs-user/TodoAPI/venv/bin/gunicorn \
    --access-logfile -  \
    --workers 3 \
    --bind unix:/run/gunicorn_TodoAPI.sock \
    config.wsgi:application
[Install]
WantedBy=multi-user.target

and

# Save and close the file then set proper permission to the Django project directory
$ chown -R www-data:ecs-user ~/TodoAPI

# reload systemd daemon
$ systemctl daemon-reload

# start and enable gunicorn_TodoAPI service
$ systemctl start gunicorn_TodoAPI.service
$ systemctl enable gunicorn_TodoAPI.service
# check 
$ systemctl status gunicorn_TodoAPI

Nginx setup

# /etc/nginx/conf.d/TodoAPI.conf
# This configuration will be changed to redirect to HTTPS later
server {
  server_name               server_adress;
  listen                    80;
  location / {
    include proxy_params;
    proxy_pass http://unix:/run/gunicorn_TodoAPI.sock;
  }
}

Setup

$ nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
sudo systemctl restart nginx

Ishga tushirish

python manage.py runserver

Default qiymatlar

Admin panelga kirish uchun superuser ma'lumotlari

username = superuser
password = superuser

Google oauth2 ni sozlash

GoogleOauth2.md ga qarang

About

Todo API


Languages

Language:Python 98.6%Language:Dockerfile 1.4%