You can customize the application using environment variables
Variable | Description | Default value |
---|---|---|
Django settings | ||
ALLOWED_HOSTS | Comma separated values of hosts for django setting ALLOWED_HOSTS. Django docs | 127.0.0.1,localhost |
DEBUG | Django docs | False |
TIME_ZONE | Django docs | UTC |
Database settings | ||
DATABASE_ENGINE | Django database engine that will used for ORM | django.db.backends.postgresql_psycopg2 |
DATABASE_NAME | Your database name | gachichat |
DATABASE_HOST | Your database host name | 127.0.0.1 |
DATABASE_PORT | DB port | 5432 |
DATABASE_USER | Username for DB auth | postgres |
DATABASE_PASSWORD | Password for DB auth | |
Other settings | ||
SECRET_KEY | Secret key for hashing and encoding | |
USER_TOKEN_EXPIRING | Count of seconds for JSON Web Token lifetime | 604800 |
Create new user for chosen room
JSON POST Data:
room_id - Numeric value for id of the room for registration
password [optional] - Password for the room. If password is setted
Response:
{
token: 'yourAPItoken'
first_name: 'maria'
last_name: 'hart'
created: 1557492563
expired_in: 1558097363
}
Get information of user
Headers:
{
Authorization: 'yourAPItoken'
}
Response:
{
first_name: 'maria'
last_name: 'hart'
}
Create random named room and user for this room
JSON POST Data:
password [optional] - Password for creating room. If you set it, your room will be private.
name [optional] - Name of the creating room. Default is random words.
description [optional] - Description of the creating room.
Response:
{
user: {
token: 'yourAPItoken'
first_name: 'maria'
last_name: 'hart'
created: 1557492563
expired_in: 1558097363
}
room: {
id: 10
name: 'Soap_Laptop'
description: ''
created: 1557492563
password: 'qwerty12+'
}
}
Get information of room
Headers:
{
Authorization: 'yourAPItoken'
}
Response:
{
name: 'Soap_Laptop'
description: ''
link: ''
created: 1557492563
}
Send message to room
Headers:
{
Authorization: 'yourAPItoken'
}
Response:
{
id: 19
text: 'Hello. This is text of message'
created: 1557615906
user: {
id: 14
}
room: {
id: 5
}
}
Getting all or filtered messages
Headers:
{
Authorization: 'yourAPItoken'
}
GET arguments:
offset [optional] - count of messages for offset
count [optional] - numeric value of count messages in response
Response:
[
{
id: 19
text: 'Hello. This is text of message'
created: 1557615906
room: {
id: 5
}
user: {
id: 14
}
}
]
It's very easy. Follow the instructions:
- Install the Python interpreter using the batch manager of your operating system.
- Create virtual environment
$ virtualenv venv -p python3 --no-site-packages
Running virtualenv with interpreter /bin/python3
...
done
- Enter to virtual environment
$ source venv/bin/activate
- Install all dependencies using pip
(venv) $ pip install -r requirements.txt
Collecting...
...
Successfully installed...
- Install PostgreSQL using your package manager of your OS
- Run it like a daemon
$ systemctl start postgresql.service
- Open PostgreSQL console
$ sudo -u postgres psql postgres
- Create database
# create database gachichat owner postgres
- That is all. Just log out from postgres user by pressing
CTRL + D
If you have difficulties with postgresql consult your operating system documentation
After the previous two steps you need to enter again the virtual environment (step 3 in python) and apply all migrations
(venv) $ python manage.py migrate
That's all. You awesome. Just run
(venv) $ python manage.py runserver
And have fun!