|
3 hours ago | |
---|---|---|
client | 3 hours ago | |
python_avatars | 2 weeks ago | |
.gitignore | 3 hours ago | |
LICENSE | 2 weeks ago | |
README.md | 3 hours ago | |
avatars.py | 15 hours ago | |
config.example.json | 16 hours ago | |
game.py | 19 hours ago | |
lobby.py | 14 hours ago | |
names.py | 15 hours ago | |
ratelimiter.py | 14 hours ago | |
server.py | 14 hours ago | |
test-ratelimiter.py | 14 hours ago | |
user.py | 2 days ago | |
welcome.py | 14 hours ago |
README.md
Quizeto
Quizeto is a WebSocket-based quiz hosting server and website client that allows users to create, host, and participate in quiz games. The server is built in Python and uses WebSockets to facilitate real-time interaction between the host and participants. The website uses standard HTML5, CSS and JavaScript without frameworks.
This is not an open source clone of Kahoot.
Version
1.0.0
Setup and Running the Server
Requirements
- Python 3.7 or higher
- WebSockets library
Installation
- Clone the repository or download the source code.
- Install required Python libraries through your distribution, e.g.
sudo pacman -Sy python-websockets
or locally if you must:pip install --user websockets
.
Configuration
config.json (Server)
Create the config.json
(or copy the example file config.example.json
) file with SSL certificate
paths if using SSL. In the access_tokens section, specify each token and its expiry date (use null
for permanent tokens).
{
"ssl_certificate": "/path/to/ssl_certificate.crt",
"ssl_key": "/path/to/ssl_key.key",
"access_tokens": {
"secretPermanentToken1": null,
"secretPermanentToken2": null,
"secretTemporaryExpiringToken1": "2156-12-31",
"secretTemporaryExpiringToken2": "2023-06-30"
}
}
When hosting a quiz in production, the host will be prompted to enter an access token. This token is validated against the entries in config.json. If valid (and not expired for temporary tokens), the host can create and manage the quiz session.
In local development mode, running without SSL, the access token requirement is bypassed.
You can always force it through server.py --access
.
Security Note
Ensure the config.json file's location and permissions are secure on the server, as it contains sensitive data like SSL paths and access tokens. The file is added to .gitignore to prevent accidental version control commits.
config.js (Client)
Create the file client/config.js
(or copy the example file client/config.example.js
) with
your domain and port. You can change the port by using a commandline argument for python server.py
(see below)
const socketDomain = "yourdomain.com"; // Replace with your server's domain
const socketPort = "49005"; // Replace with your desired port, same as server.py --port 49005
Running the Server
- To start the server with SSL (default):
python server.py
- To run the server without SSL (useful for development):
python server.py --no-ssl
- To start the server with a custom configuration file:
python server.py --config-file /path/to/custom_config.json
- To use a custom socket port:
python server.py --port 49005
Deployment of the Website Client
To deploy Quizeto on a web server:
- Copy Web Files: Copy the client-side files, everything in the
client
directory, to your web server's hosting directory. This includes the fileconfig.js
, that you created yourself (see above) but and NOT config.json. - Configure Your Web Server: Set up a web server like Apache or Nginx to serve these files. Ensure the server is configured to serve over HTTPS if you're using WebSockets over SSL (WSS).
- WebSocket Server: Run the Quizeto WebSocket server (
server.py
) on the same server or a different server. Ensure that the WebSocket server is accessible to the clients.
Additional Information
For detailed information on commands and configuration, run python server.py --help
.
Local Usage for development
When running locally and without SSL the token file will not be used and you can just click the host button.
Internal Notes to host on Uberspace
uberspace port add
Port 49005 will be open for TCP and UDP traffic in a few minutes.
Your application needs to listen on interface :: or 0.0.0.0 (using 127.0.0.1, localhost, ::1, the external IP, or the hostname will not work).
Other Code
- https://github.com/ibonn/python_avatars (included)
- https://davidshimjs.github.io/qrcodejs/ (included)
- with this patch: https://github.com/davidshimjs/qrcodejs/issues/292