We require a web server that will receive requests from the user and process them. The web server will pass the request to the application, which will check what kind of request it is and process accordingly. When we execute our Sinatra application, it starts a web server that listens for requests on a particular port.
If you recall the application file structure that we had discussed in Chapter 3, Hello World, you will find a file named app.rb
. This file will be our main application file that will load all the models and handle all the requests.
The main application file loads all the Ruby gems, connects to the database, and loads all the models. It also manages requests for all the defined routes. A route is a valid HTTP request that the given application can understand and process.
Writing the application file is very simple. So, let's start it right away!