On This Day is an application built with Sinatra and React that returns events, births and deaths that occurred in a specific day. This information has been retrieved from Wikipedia by using a scraper.
Currently available at https://onthisday.salatart.com
Returns an array of JSON historical events, filtered by day and month.
-
URL:
/events?day=<day>&month=<month>
-
Method:
GET
-
URL Params
day=[integer]
, any number between 1 and 31month=[integer]
, any number between 1 and 12 -
Data Params
None
-
Success Response:
- Code: 200
- Example content:
{ id: 359, day: 25, month: 12, description: "December 25 is the 359th day of the year (360th in leap years) in the Gregorian calendar. There are six days remaining until the end of the year. This date is slightly more likely to fall on a Tuesday, Friday or Sunday (58 in 400 years each) than on Wednesday or Thursday (57), and slightly less likely to occur on a Monday or Saturday (56).", events: [ { id: 122616, year: 2015, bce: false, episode_type: "event", text: "Mohammed Zahran Alloush, commander of Jaysh al-Islam (Army of Islam), one of the Syrian opposition factions, is killed by an airstrike.", day_month_id: 359 }, { id: 122615, year: 2012, bce: false, episode_type: "event", text: "An Antonov An-72 plane crashes close to the city of Shymkent, killing 27 people.", day_month_id: 359 }, { ... } ] }
-
Error Response:
- Code: 400
- Content:
{ error: "Not a valid request." }
-
Sample Call:
$.ajax({ url: "/events?day=25&month=12", dataType: "json", type : "GET", success : function(response) { console.log(response); } });
The API is the same for births and deaths, but instead of making a call to /events
, it should be done to either /births
or /deaths
.
- Clone and cd into this repository
- cd into
client
and runnpm run build && npm start
- cd back into the root dir of this repository
- cd into
server
and runbundle install
- Run
rake db:reset
- Run
shotgun config.ru
# Pull and run the application and PostgreSQL
$ docker run -d --name=postgres_db postgres:9.6.1
$ docker run -d --name=onthisday -p 80:9292 --link=postgres_db:postgres_db sasalatart/onthisday
# Setup the database
$ docker exec onthisday rake db:reset
The server's machine should now be redirecting its port 80 to the container's port 9292.