This project aims at providing a simple way to self-host a survey and store its results in a self-hosted database.
The following features are included :
- Survey import from JSON file
- No registration required, 100% anonymous vote
- Only one vote per user*
- Verification that the user has visited the poll page
* this is done by storing a hash of the IP address and user-agent combination, which seems a good enough heuristic according to a study by the EFF
The database stores 3 kinds of information :
- the polls themselves
- the raw results (as delivered by survey-js)
- the interpreted results
- Clone the project
- Install dependencies :
pip install -r requirements.txt
- (optional, if using SQLite) Setup your database
- Setup a
.env
file in the root directory withSQLALCHEMY_DATABASE_URI
andSECRET_KEY
- Upgrade the database :
flask db init && flask db migrate -m "Initial" && flask db upgrade
- Run the app
flask run
Surveys can be written 'by hand' or built using the free online survey-js Builder which exports the survey as a JSON file.
- Move the file to some location accessible from the host machine
- Import the poll : ̀
flask poll import /path/to/json "optional poll name"
- The poll is now accessible from
http://your_host/polls/<slugified-poll-name>
and the results can be seen athttp://your_host/polls/<slugified-poll-name>/results
The JSON file can now be safely deleted.
Raw poll results can be converted into a poll-specific model that will be stored into the database, in order to ease analysis and querying on the results.
- Create the model and upgrade the database :
poll upgrade
- Convert the results :
poll convert
Repeat step 2. as many times as necessary over the poll lifetime.
This project relies on the following free pieces of software awesomeness :
- Flask web framework
- Flask SQLAlchemy integration
- Flask-Migrate
- survey-js library
- python-slugify
- python-dotenv
The survey-js is included through a CDN.