#100DaysOfWeb in Python Transcripts
Chapter: Day 50: Responder framework
Lecture: Adding the 'hello world' view method

Login or purchase this course to watch this video and the rest of the course contents.
0:00 Let's get started by just defining the most basic web app that we can with responder. And then we're going to add some templated views
0:07 and some API methods. And also, when we get started we're going to build it all in this jammed-together
0:12 app.py file, and then I'll show you one way at least to restructure it in a much much better way with API views broken out, and page views
0:22 and routes and all the stuff that you would probably want to do for real apps broken apart in a much better way.
0:27 But we're going to start by jamming it in here. So, let's get started. Now, when you think of this API
0:32 it's Flask-inspired but it's not exactly the same as Flask. A lot of what you do, before mirroring Flask we did like Flask.app like this, Flask app.
0:43 Here, we're going to say responder.api, like so. We're going to create this and then on to various methods we can say app.route, to add a route.
0:51 So let's say we want one for the home view and this will be index and this is going to take a request, and a response.
0:58 This is unlike Flask, which doesn't take these. And then, what we can do is we can just say response.content = "Hello world".
1:07 Alright, now if we run this it's going to be not so inspiring, it just exits. The last thing we've got to do is
1:13 we've got to go down here and say app.run. If we do this, clean it up a little and we run it it's up and going, let's see what we've got.
1:22 Hello world, there we go. Hopefully you can tell this is a pretty simple API and it's also quite Flask-inspired in the way that it works.
1:32 Obviously, we want to replace this with some kind of templated view maybe an overall layout page and individual page details like we have in some
1:40 of the other templated frameworks and things like that. We'll get to that but here is a really nice way to get started.


Talk Python's Mastodon Michael Kennedy's Mastodon