Responder Web Framework Mini-course Transcripts
Chapter: Building a RESTful API with Responder
Lecture: Adding the 'hello world' view method
0:00 Let's get started by
0:01 just defining the most basic web app
0:03 that we can with responder.
0:04 And then we're going to add some templated views
0:06 and some API methods.
0:08 And also, when we get started
0:09 we're going to build it all in this jammed-together
0:11 app.py file, and then I'll show you one way at least
0:15 to restructure it in a much much better way
0:17 with API views broken out, and page views
0:21 and routes and all the stuff that
0:22 you would probably want to do for real apps
0:25 broken apart in a much better way.
0:26 But we're going to start by jamming it in here.
0:28 So, let's get started. Now, when you think of this API
0:31 it's Flask-inspired but it's not exactly the same as Flask.
0:35 A lot of what you do, before mirroring Flask
0:37 we did like Flask.app like this, Flask app.
0:42 Here, we're going to say responder.api, like so.
0:46 We're going to create this and then on to various methods
0:48 we can say app.route, to add a route.
0:50 So let's say we want one for the home view
0:53 and this will be index
0:54 and this is going to take a request, and a response.
0:57 This is unlike Flask, which doesn't take these.
1:00 And then, what we can do is
1:01 we can just say response.content = "Hello world".
1:06 Alright, now if we run this
1:07 it's going to be not so inspiring, it just exits.
1:11 The last thing we've got to do is
1:12 we've got to go down here and say app.run.
1:14 If we do this, clean it up a little and we run it
1:18 it's up and going, let's see what we've got.
1:21 Hello world, there we go. Hopefully you can tell
1:24 this is a pretty simple API
1:26 and it's also quite Flask-inspired
1:29 in the way that it works.
1:31 Obviously, we want to replace this
1:33 with some kind of templated view
1:34 maybe an overall layout page
1:37 and individual page details like we have in some
1:39 of the other templated frameworks and things like that.
1:42 We'll get to that but here is a really nice way to get started.