Django с PostgreSQL в Astra Linux SE 1.5

Устанавливаем необходимые пакеты с зависимостями: postgresql, python-psycopg2. В ALSE 1.5 основная версия PostgreSQL 9.4.5. Редактируем конфигурационный файл базы данных $ sudo vim /etc/postgresql/9.4/main/pg_hba.conf Комментируем или удаляем все строки и дописываем новые, разделяя поля табуляцией local all postgres trust local all all trust host all all 127.0.0.1/32 trust host all all 192.168.15.129/24 trust host all all 192.168.15.132/24 trust Последние строки - адреса сервера и клиента, которым будем подключаться. Меняйте на свои или укажите всю сеть, например 192....

February 19, 2022

Web-приложение на Python в Astra Linux с ALD авторизацией

Как настроить сервер - контроллер домена ALD и подключиться к нему клиентом в статье Настройка входа в систему с Astra Linux Directory. Устанавливаем web-сервер (если еще не установлен), нужные нам модули apache и пакет с django $ sudo apt-get install apache2 libapache2-mod-auth-kerb libapache2-mod-python python-django Включаем модули apache, с которыми будем работать, отключаем лишний auth_pam, если ранее с ним работали, затем запускаем web-сервер $ sudo a2dismod auth_pam $ sudo a2enmod python $ sudo a2enmod auth_kerb $ sudo service apache2 reload Создаем принципала в ALD и добавляем его в группу mac...

February 18, 2022

Запуск Django-приложений через mod_python в Astra Linux SE 1.5

Считаем, что Apache уже установлен и настроена аутентификация и авторизация через PAM (см. Настройка web-сервера на Astra Linux SE 1.5) Устанавливаем необходимые пакеты: # apt-get install libapache2-mod-python python-django Включаем модуль: # a2enmod python Создаем проект Django и каталог для log-файлов: # cd /var/www # django-admin startproject django_site # mkdir django_site/log В /etc/apache2/sites-available/ создаем файл django_site. Это файл конфигурации виртуального хоста для нашего Django-проекта, лежащего в каталоге /var/www/django_site/. <VirtualHost *:80> ServerAdmin webmaster@domain....

February 4, 2022

Starting a production Django server

I wrote ansible playbook for starting up a production Django server with PostgreSQL, Gunicorn and Nginx. When I tested the script, I used the Ubuntu Server image from this link. All I needed to install additionally was an ssh server for ansible to work. sudo apt update && sudo apt upgrade sudo apt install openssh-server I used a VirtualBox image and set the network settings to bridge mode. The IP address was obtained via the dhcp protocol....

October 15, 2021

Deploying the django app on the DigitalOcean App Platform

For deploying Django apps, I tried PaaS such as Heroku and Pythonanywhere. It’s the turn of the DigitalOcean App Platform. And so far, this is the easiest and fastest way to deploy a Django app in production. There is awesome guide on how to do this on DigitalOcean’s tutorials. For testing, I wrote a small application that generates a configuration snippet for configuring ssh on cisco devices. For simplicity, I didn’t use a database and static content....

July 21, 2021

Creating dockerized Django app with VSCode

Thanks to Mark Winterbottom for the interesting videos and the idea for this post. Creating a Django project Start by creating a new directory for your project (eg: vscode-django-docker), and open it in VSCode. mkdir vscode-django-docker cd vscode-django-docker git init code . Then, add a .gitignore for your project. You can use template for Python provided by GitHub or generate on gitignore.io. Now let’s create a Django project by running the one-line-command below...

June 12, 2021

Django project deployed on Heroku

About a year ago, I published a web-based task management application written with Flask. It looked like this: Since a year has passed, I decided to rewrite this project in Django, and also try to deploy it to PaaS Heroku. I’ve also made some improvements, including design, authorization, database management, and web security issues. That’s what happened: Links: Try it in live on Heroku GitHub repository

March 25, 2021

Django REST API with React App step-by-step

I use PyCharm for python projects and pipenv for package management. Start new PyCharm project named django-rest-react-blog Optionally git init clone gist .gitignore for Django and React projects Main course pipenv install django pipenv install djangorestframework pipenv install ipython --dev django-admin.py startproject bookcase cd bookcase python manage.py startapp mainapp Edit bookcase/settings.py: ... INSTALLED_APPS = [ ... 'rest_framework' ] ... TEMPLATES = [ { ... 'DIRS': [BASE_DIR / 'mainapp-ui/build'], ... }, ] ....

February 27, 2021

Facial recognition with Python

I tried the facial recognition library for Python ageitgey/face_recognition. This library uses dlib, a toolkit written in C++ that contains machine learning algorithms. For example, I’m trying to check if an actor is playing in the TV series “The Big Bang Theory”. A test image with an actor is compared to real actors filmed in a TV show. I wrote a web service that uses python face_recognition library for face recognition from image and compares the recognized face with the data stored in the database....

January 18, 2021