Bingo Survey is a webapp that allows for the formatting of a survey as a bingo board. This allows for a more interactive and fun way to conduct surveys. Administrators can create boards, and users can fill them out. The results are then stored in a database and can be exported to a CSV file.
Clone the repository.
Create a virtual environment using venv:
python -m venv venv
Install the required packages using pip:
pip install -r requirements.txt
Create a .env
file in the root directory with the following contents:
SECRET_KEY="<your_secret_key>"
DATABASE_URI="mysql://username:password@address:port/database"
SESSION_COOKIE_SECURE=<True/False>
SESSION_COOKIE_HTTPONLY=<True/False>
SESSION_COOKIE_SAMESITE="<Strict/Lax/None>"
SECRET_KEY
is used to encrypt the session cookies. To generate one, consider using the secrets
module in Python. For example:
import secrets
secret_key = secrets.token_hex(25)
print(secret_key)
You can change the length of the secret key by changing the number in secrets.token_hex()
. Replace your_secret_key
with the generated secret key.
DATABASE_URI
is the URI to your database. The general format is mysql://username:password@address:port/database
. Replace username
, password
, address
, port
, and database
with your database's information. If your database software is different, you can change the URI to match your database's URI. Keep in mind that this app was developed using SQLAlchemy, so the URI should be compatible with SQLAlchemy.
SESSION_COOKIE_SECURE
determines if the session cookie is secure. If you are using HTTPS, set this to True
. If you are using HTTP, set this to False
.
SESSION_COOKIE_HTTPONLY
determines if the session cookie is HTTP only. If you want to prevent JavaScript from accessing the session cookie, set this to True
. If you want JavaScript to access the session cookie, set this to False
.
SESSION_COOKIE_SAMESITE
determines the SameSite attribute of the session cookie. If you want to prevent the session cookie from being sent in a cross-site request, set this to "Strict"
. If you want the session cookie to be sent in a cross-site request, set this to "Lax"
. If you want the session cookie to be sent in a cross-site request and you want to prevent the session cookie from being sent in a cross-site request from a different site, set this to "None"
.
start_dev.sh
or start_dev.bat
:For Linux and macOS:
./start_dev.sh
For Windows:
start_dev.bat
Thanks to snorklerjoe for the Docker deployment setup and instructions! I'll copy them here, or you can view the original instructions at docker/README.md
. Keep in mind that these instructions are meant to be followed in the docker
directory.
Docker-Compose is used to create two containers--
If you are not already in the docker
directory, navigate there:
cd docker
To build the production images, from this directory, run
docker compose build
To use the production containers, after building, create a .env
file of the following sort:
# Required for the Flask app
SECRET_KEY="CHANGE THIS"
SESSION_COOKIE_SECURE=False
SESSION_COOKIE_HTTPONLY=True
SESSION_COOKIE_SAMESITE="<Strict/Lax/None>"
# For communication with the database
MYSQL_PASSWD="ChangeThisPasswd"
# Ports to bind to; specify if different ports are required
#HTTP_PORT=80
#HTTPS_PORT=443 # Irrelevant if cert/key are not specified
# For SSL/TLS; Both SSL_PEM and SSL_KEY must be specified
#SSL_CERT="/path/to/ssl.cert"
#SSL_KEY="/path/to/ssl.key"
... and then run
docker compose up
to start the containers, and
docker compose down
to stop and remove/clean up the containers.
A volume will be automatically created by docker-compose for database persistence. Even after rebuilding the images or stopping the containers, this volume will still be present until deleted manually.
The app container will not start until the database has passed its healthcheck and is ready to start receiving requests. See docker-compose.yaml
.
To test SSL/TLS functionality, generate a self-signed certificate. To use openssl, simply run the following:
openssl req -nodes -new -x509 -keyout server.key -out server.cert
Then, in the .env
mentioned above, use the following lines:
SSL_CERT="server.key"
SSL_KEY="server.cert"
There is no need to rebuild the images if already built, but the containers should be restarted for the change to take effect.
A self-signed certificate should not be used in production. Obtain keys from LetsEncrypt or similar.
nocert.pem
and nokey.pem
should be left as blank files- these are bind-mounted as volumes to the container if no keys are specified in the .env
and should be blank so the server knows not to try to run in SSL/TLS mode.
Everything for administration is done through the command line (for now).
The administration script is located at admin/admin.py
. To run the script, use the following command:
python admin/admin.py
You will be greeted with a menu. The CLI is (in my opinion) very intuitive—and dare I say, friendly—but everything you need to know is located in the GitHub Wiki for this project.
BingoSurvey originated from a request from a friend I know from Lafayette College. He asked me if I knew of any websites that allowed for a progressive game to be played with a bingo board style survey component. He was planning a game about networking and wanted to have a week-long game where people could fill out a survey in the form of a bingo board. Since I couldn't find any websites that did this (and I was on spring break), I decided to make one myself.
Here's a short (hopefully up-to-date) list of features that I'd love to implement in the future:
If you find a bug, please create an issue on GitHub and add the "bug" label. Please include as much information as possible, such as the steps to reproduce the bug, the expected behavior, and the actual behavior.
If you have any ideas for features, please let me know by creating an issue on GitHub and adding the "suggestion" label. Or, if you're feeling ambitious, you can fork the repository and create a pull request with your feature implemented! There are no requirements for contributing, apart from ensuring that your code is documented.
If you have any questions, please feel free to reach out to me:
Copyright (C) 2024 Jackson Eshbaugh
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, version 3 of the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License (LICENSE) for more details.