Debate voting tool implementation code explanation

Code address: https://gitee.com/Brickie_liu/bianlun-vote

origin of a thing

New students in the unit want to hold a debate, and colleagues in the trade union want a voting function, similar to the projected on the big screen, and the audience can choose their opinions through their mobile phones. Considering that I haven't seen this type of gadget yet, and I know some teachers, I will organize these activities in the class. This interactive activity can be more dynamic than a mere debate.

Second finishing needs

1. The audience voting information will be displayed in real time on the big screen of the debate.
2. The voting method is supported. Each person can only vote one vote and cannot be changed. Each person can only vote one vote but can be changed. Each person can vote repeatedly.
3. You can add or delete debate topics, and count staged votes.
4. Use scenarios, conference hall for 50-200 people.

Three demonstration videos:

https://gitee.com/Brickie_liu/bianlun-vote/tree/master/test/vote-1.mp4
https://gitee.com/Brickie_liu/bianlun-vote/tree/master/test/vote-2.mp4

Four scheme one (WNMP, PHP, Nginx, Vue)

Considering the above functions, I think it can be used on the public network server when there is no intranet, and the WNMP environment can be packaged when there is no network, so as to simplify functions and deploy as much as possible.

development environment

win10 64-bit
notepad++
WNMP

third party library

front end:

bootstrap
VUE

rear end

PHP websocket( https://github.com/Textalk/websocket-php)
PHP Psr\Log

Project directory structure

│  index.html
│  manage.html
│  readme.txt
│  userListConfg.txt
│  util.php
│  vote.php
│  voteAdmin.html
│  voteConfig.php
│  voteOpt.php
├─lib
│  ├─Psr
│  │  └─Log
│  └─WebSocket
│          BadOpcodeException.php
│          BadUriException.php
│          Base.php
│          Client.php
│          ConnectionException.php
│          Exception.php
│          Server.php
│          TimeoutException.php
├─res
└─sh
        voteStartAll.php
        voteStopAll.php

existing problems

1. Since I was thinking of deploying on a public network server at that time, it is still necessary to configure a lot of system configurations for professional deployment, which is very cumbersome .
2. Deployment in the local environment is a bit difficult, not foolish. Ordinary people won't use it. Can't do click to run.

Five scheme two (python, tk)

Aiming at the problem of scheme 1, implement it with python and integrate web services. Package into exe, install and run.
Not considering supporting deployment on public network servers, only supporting local, 50-200-person conference hall [one computer, one WIFI6 router supporting 3000M ] Huawei's theory supports 128 terminals.

development environment

win10 64位
winrar
anaconde3 py39,
pycharm 2021.2

third party library

front end

WEB bootstrap
WEB VUE
GUI tkinter

rear end

psutil, get system local information
gevent, websocket service
gevent-websocket, websocket service
pyinstaller, generate exe packaging
bottle , web service framework with only one file, follow WSGI, and support almost all commonly used functions. Personal development of small WEB recommendations.

Project directory structure

│  build-winrar-conf.ini
│  build.bat
│  build.ps1
│  README.md
│  requirements.txt
│  voteMain.py
│
├─app-dist
│   voteMain.exe
│   voteMain.rar
│
├─src
│    app_gui.py
│    app_http.py
│    bottle.py
│    http_server.py
│    util.py
│
├─tool
│  │  upx-3.95-win64.zip
│  └─upx-3.95-win64
│          upx.exe
│
└─www
    │  404.html
    │  manage.html
    │  vote_client.html
    │
    └─res

compile

1. Secondary packaging tool winrar, the installation path is "C:\Program Files\WinRAR\WinRAR.exe", if not, please modify build.batthe winrarparameters.

2. Win10: Open anaconda promptthe terminal to execute build.bat, app-distgenerate in the directory exe, rarand the source data directory voteMain.

3. build.ps1It is powershellan execution script in the environment, and has not been tested.

Scenario deployment

Local, conference hall for 50-200 people [one computer, one WIFI6 router supporting 3000M ] Huawei’s theory supports 128 terminals.

Deployment plan 1: less than 100 people

Required hardware equipment: one computer, one router

无线链接
无线链接
WIFI-6路由器
电脑web服务器
手机

Deployment plan 2: When there are more than 100 people in the school, use 2-3 WIFI6 to make a simple local network.

Need hardware equipment: one computer, 2-3 routers

链接
有线AP
有线AP
无线链接
WIFI-6路由器
电脑web服务器
WIFI-6
WIFI-6
手机
手机
手机

install and run

1. Use rardecompression to install, generate the source file directory, enter to find voteMain.exeand run.

2. Use exethe installation to generate the source file directory, and generate a shortcut on the desktop, double-click to run.

3. cmd operating parameters

Usage: voteMain.exe [options]

Options:
  -h, --help            show this help message and exit
  -p PORT, --port=PORT  指定web服务端口,默认值【8080】
  --gui               GUI运行,默认值【True】

question of existence

none

Guess you like

Origin blog.csdn.net/liuzhuchen/article/details/121686798