This project is a polling application that includes a frontend built with React and a backend developed using Django Rest Framework. The frontend and backend are connected via API and are hosted on separate domains.
- Create polls with multiple choices in a single API call.
- Vote for choices in the latest poll.
- Ensures each device can only vote once per poll by combining IP address and user-agent as a unique identifier.
-
Clone the Repository:
git clone https://github.com/kushal1o1/LivePoll.git cd polling-app-backend
-
Create and Activate a Virtual Environment:
python -m venv venv source venv/bin/activate # On Windows use `venv\Scripts\activate`
-
Install Dependencies:
pip install -r requirements.txt
-
Run Database Migrations:
python manage.py migrate
-
Create a Superuser:
python manage.py createsuperuser
-
Start the Development Server:
python manage.py runserver
-
Access the Admin Panel at
http://127.0.0.1:8000/admin
.
-
Clone the Repository:
git clone https://github.com/kushal1o1/LivePoll.git cd polling-app-frontend
-
Install Dependencies:
npm install
-
Start the Development Server:
npm start
-
Access the Frontend at
http://localhost:3000
.
- URL:
/polls/
- Method:
POST
- Body:
{ "question": "What's your favorite color?", "choices": [ {"choice_text": "Red"}, {"choice_text": "Blue"}, {"choice_text": "Green"} ] }
- URL:
/polls/{poll_id}/vote/
- Method:
POST
- Body:
{ "choice_id": 1 }
- Frontend (React): Communicates with the Django backend using AJAX requests to the API endpoints.
- Backend (Django Rest Framework): Provides the API endpoints for creating polls, managing choices, and recording votes.
- Frontend: Hosted on livepoll.vercel.app
- Backend: Hosted on livepoll.pythonanywhere.com
Ensure that the frontend is configured to point to the backend API endpoint for proper functionality.
This project is licensed under the MIT License - see the LICENSE file for details.