mscoutermarsh / Mathy Poll
Voting API with basic match CAPTCHA.
Stars: ✭ 11
Programming Languages
ruby
36898 projects - #4 most used programming language
Mathy-Poll
A Grape/Goliath API for tracking votes. With simple math captcha!
- Vote is created.
- API asks a simple math question (What's 2+2?).
- If user answers correctly. Vote is counted in poll.
Very simple rate limiting by IP address.
Demo:
See a live demo: Mathy-Poll on Heroku
Screenshot:
Setup:
Clone the repo:
git clone https://github.com/mscoutermarsh/Mathy-Poll.git
cd Mathy-Poll
Install gems:
bundle install
Setup the database:
rake db:setup
Start the server!
ruby server.rb -vs
Heroku:
Deploy toCreate a new app.
heroku apps:create APPNAMEHERE
Run migrations
heroku run rake db:migrate RACK_ENV=production
Check out your new poll on heroku!
yourappname.herokuapp.com
API Documentation:
Create a new Vote
http POST 0.0.0.0:9000/vote/1
This will return the vote id and the math question:
{
"id": 7,
"question": "What's 13+3?"
}
Now to confirm your vote... answer the question by POSTing to /vote/confirm/:id/:answer.
http POST 0.0.0.0:9000/vote/confirm/7/16
If your math is correct, the vote will be confirmed.
{
"message": "Thanks for voting!"
}
Get number of votes
To see how many votes there are for contestant #1.
http GET 0.0.0.0:9000/votes/1
And it will return:
{
"votes": 4
}
Performance Specs on Heroku
Goliath/Grape handles high loads really well. This has been tested at 200-300 requests per second on a single Heroku dyno.
1 Dyno:
Transactions: 12715 hits
Availability: 99.99 %
Elapsed time: 59.85 secs
Data transferred: 0.13 MB
Response time: 0.44 secs
Transaction rate: 212.45 trans/sec
Throughput: 0.00 MB/sec
Concurrency: 94.16
Successful transactions: 12715
Failed transactions: 1
Longest transaction: 11.56
Shortest transaction: 0.08
Need help?
- Twitter @mscccc
- mikecoutermarsh.com
Credits
- Based off of: Grape-Goliath-Example
Note that the project description data, including the texts, logos, images, and/or trademarks,
for each open source project belongs to its rightful owner.
If you wish to add or remove any projects, please contact us at [email protected].