This web application allows the dynamic assignment of teams to stations, managing a queue for teams waiting for available stations, and providing real-time updates for both team assignments and the queue.
- Assign Teams to Stations: Teams can be assigned to the highest available active station.
- Queue Management: Teams can be added to the queue when no stations are available.
- Auto-remove: Teams are automatically removed from stations after 5 minutes unless manually removed.
- Real-time Updates: The current team assignments and queue are updated in real-time every 5 seconds without requiring a page refresh.
To run this application, you need the following:
- Python 3.7 or higher
- Flask
- Additional Python libraries (
threading,time)
Clone the repository to your local machine using Git:
git clone https://github.com/yourusername/team-station-assignment.git
cd team-station-assignmentIt’s recommended to use a virtual environment to avoid conflicts with other projects.
-
Create a virtual environment:
python3 -m venv venv
-
Activate the virtual environment:
- On Windows:
venv\Scripts\activate
- On Mac/Linux:
source venv/bin/activate
- On Windows:
-
Install required dependencies:
pip install flask
To start the application, run the following command:
python app.pyThe application will be available at http://127.0.0.1:5000/ by default.
- Main page (
/): The home page where you can assign teams to stations and manage station statuses. - Assignments page (
/assignments): A separate page displaying the current station assignments and team queue. This page updates in real-time every 5 seconds. - Station Status page (
/station): A page to where each station can access the information about station assignments and team queues, and alert the main page when a team has arrived to the station and a new team is ready to be assigned.
The assignments and station pages uses AJAX polling to fetch the latest team assignments and queue every 1 seconds without requiring a page refresh. This ensures that all users see the most up-to-date data without needing to reload the page manually.
-
/assign: Assign a team to the highest available active station. The team is added to the queue if no stations are available.- Method:
POST - Body: JSON with the team name.
- Example Request:
{ "team": "Team A" }
- Method:
-
/remove: Remove a team from a station or queue.- Method:
POST - Body: JSON with the team name.
- Example Request:
{ "team": "Team A" }
- Method:
-
/toggle_active: Toggle the active status of a station (activate or deactivate).- Method:
POST - Body: JSON with the station number.
- Example Request:
{ "station": 1 }
- Method:
-
/get_assignments: Retrieve the current team assignments and the team queue as JSON.- Method:
GET - Example Response:
{ "stations": { "1": "Team A", "2": null, "3": "Team B" }, "active_status": { "1": true, "2": false, "3": true }, "team_queue": ["Team C", "Team D"] }
- Method:
To deploy this app to a cloud platform (e.g., Vercel, Heroku), follow these steps:
-
Install Vercel CLI:
npm install -g vercel
-
Link your project:
vercel
-
Follow the prompts to deploy.
-
After deployment, the app will be available at the URL provided by Vercel.
-
Install Heroku CLI:
brew install heroku
-
Create a
Procfilewith the following content:web: python app.py -
Log in to Heroku and create a new app:
heroku login heroku create
-
Deploy your app to Heroku:
git push heroku master
-
Open the deployed app:
heroku open
This project is licensed under the MIT License - see the LICENSE file for details.
Andrew T. Pipo
937-631-5036
This README provides all necessary information to run, test, and deploy the application. For any issues or contributions, feel free to submit an issue or pull request.
