A simple messenger written essentially in Python and Django
Private Chat is a open source project what makes the function of an instant messenger. This is done with a back-end system written essentially in Python and Django.
Available on: privatechatdemo.herokuapp.com
In order for the page content to be dynamic without reloading, options were used for the client side. JavaScript along with the JQuery library has important roles for this. In the chat room, the system makes periodic requests for information about new messages and verification of read messages. This is done with AJAX requests.
![aqui deveria aparecer um icone de pessoa](https://4.bp.blogspot.com/-UNZIh6tkU7A/WFDywvLgf-I/AAAAAAAABdo/5EvlhOIstFAV7YvF4tYJLSTEHXg3DosbwCLcB/s1600/readme2.jpg “Chat Window”)
Chat window
The code in this repository is shaped for the production environment, but if all dependencies are installed, it also runs in the development environment.
First of all, have pip and virtualenv installed.
Sequence of steps:
-
Create a virtualenv for the project by prescribing Python 3:
virtualenv --python = python3 [environment name]
-
Enter the virtualenv folder and activate it:
source bin/activate
-
Make the clone or download the project into the part of the newly created virtualenv.
-
Within the project root, install pip dependencies:
pip install requirements.txt -r.
-
Run the
python manage.py makemigrations
andpython manage.py migrate
to create the application tables. -
To start run
python manage.py runserver.
Basically what the system does is identify a user action and access the database through ajax requests and bring, add or delete data to the page without having to reload the page. There are three essential files in the chat system:
chat.js
views.py
models.py
Requests are made in the chat.js
file using the JQuery library. The use of the setInterval()
is done in the requests of new messages and the confirmation of reading the message.
Each ajax function does a GET or POST has access to a view within views.py
through a route. In screen views are made of shields not to accept requests that are not AJAX and that are not of the logged in user.
For views to return information to chat.js
, instances of the models.py
class Message functions are instantiated.
The project is open for contributions, preferably with pull requests.
Contact me on diegofernanfo5672@gmail.com
:)