1 00:00:00,450 --> 00:00:03,760 Here's a workspace with our same Sinatra app from before. 2 00:00:03,760 --> 00:00:07,450 Notice I made sure to add set bind 0, 0, 0, 0 right after 3 00:00:07,450 --> 00:00:13,060 the require Sinatra lines so that I can connect to the app from a remote computer. 4 00:00:13,060 --> 00:00:17,390 We already have a route to accept get requests for the /apple path and 5 00:00:17,390 --> 00:00:20,260 returns to main HTML in the response. 6 00:00:20,260 --> 00:00:24,180 We can support additional paths by adding additional routes, one after another. 7 00:00:25,570 --> 00:00:28,313 So let's go down here to the bottom, 8 00:00:28,313 --> 00:00:32,217 we'll add another get route for a path of /banana. 9 00:00:35,079 --> 00:00:39,809 We'll give it a block which will be used to determine Sinatra's response. 10 00:00:41,660 --> 00:00:46,320 Now let's go up here and make this a level one heading, while I'm thinking about it. 11 00:00:47,950 --> 00:00:52,954 And we'll do the same here, level one heading. 12 00:00:52,954 --> 00:00:59,910 Here's a ripe banana, close our heading, and close our string. 13 00:00:59,910 --> 00:01:02,820 And then we'll set up a third route. 14 00:01:02,820 --> 00:01:09,410 Also for get request, and we'll give this one a path of /carrot. 15 00:01:09,410 --> 00:01:10,041 Set up a block. 16 00:01:13,675 --> 00:01:14,630 Level one heading. 17 00:01:16,520 --> 00:01:21,118 Here's a crunchy carrot. 18 00:01:26,495 --> 00:01:31,295 We'll be sure to save that, and then we need to go to the console and run it. 19 00:01:31,295 --> 00:01:35,730 Ruby produce.rb. 20 00:01:35,730 --> 00:01:41,370 Now we can go into the preview and reload, and there's our /apple path. 21 00:01:42,490 --> 00:01:49,102 And now we can change the path from /apple to /banana. 22 00:01:49,102 --> 00:01:51,797 And a get request for that path will be sent instead. 23 00:01:52,870 --> 00:01:54,920 When a request comes into a Sinatra app, 24 00:01:54,920 --> 00:01:58,290 it looks through the routes you've defined one by one from top to bottom. 25 00:01:59,310 --> 00:02:02,840 The first routes match both the request method, get in this case, 26 00:02:02,840 --> 00:02:07,480 and the resource path will be chosen, and the accompanying Ruby block will be run. 27 00:02:07,480 --> 00:02:11,690 So this request will match the GET /banana route in our app, the block for 28 00:02:11,690 --> 00:02:15,670 that route will be run, and we'll get different HTML in response. 29 00:02:15,670 --> 00:02:18,642 We can also change the path to /carrot, 30 00:02:20,787 --> 00:02:24,340 Which will match the third route and run the third block. 31 00:02:24,340 --> 00:02:27,348 For additional practice you should try adding more get routes to our 32 00:02:27,348 --> 00:02:28,680 produce.rb app now. 33 00:02:29,740 --> 00:02:34,030 You can also try returning different HTML strings from the existing routes. 34 00:02:34,030 --> 00:02:37,240 We'll see you in the next stage where we'll be talking about a Sinatra feature 35 00:02:37,240 --> 00:02:40,880 that will let you render not just short strings but an entire HTML page.