Static Sites with Sphinx and Markdown Transcripts
Lecture: Live reload
0:00 Sphinx is a static site generator.
0:03 SSG other Static Site Generators, Especially modern ones have nice authoring servers,
0:09 you type some stuff in the build happens.
0:11 And what's really cool is the browser automatically reloads to show you the content you're authoring
0:19 that helps during the tutorial. Let's do something similar for Python.
0:22 Using the live reload package. Live reload has a bundled web server and a way
0:30 of watching files for changes and then running some commands to rebuild things as those changes
0:37 occur. It's not perfect. It's not as good as the pretty sophisticated ones that
0:42 you see in modern web front ends.
0:44 We'll go ahead and give it a try by installing it into our virtual environment. Back
0:50 to my editor. I'm going to go to requirements.txt and add live reload
0:54 Since it's going to be helpful,
0:57 I'm gonna go ahead and let it install.
0:59 The requirement for me. Let the tool do it now that I've got live reload
1:03 in place. What I wanna do is make a file a python script that I
1:08 can run whenever content changes and this python script needs to have some information in it
1:17 about the kinds of things to watch are just chosen to be very explicit on it
1:20 So whenever my content changes,
1:23 whenever my code changes or whenever my templates or static stuff change,
1:28 I want to run that command that we just ran in the last section.
1:33 So if I run this, I'm gonna,
1:35 again, I'm gonna run it using my tool and just as a reminder,
1:38 this particular editor even live reload aren't critical for the learning in it.
1:42 And this is the tutorial step instead.
1:45 We're just using it for convenience.
1:47 So with this in place it tells me it's got a URL.
1:50 That I can go and watch my changes on.
1:53 And when I click on that it opens my browser showing me the build rendered output
2:00 that I can use to click around and make changes.
2:03 Let's see that in action by going back to my editor and I'm gonna go change
2:08 the content and for example I will remove this comment at the top when I save
2:14 You'll see that the live reload is rerunning and it's rebuilding this 'index.rst'
2:24 file and in my content I don't see any changes because of that because that wasn't
2:28 visible. I'll go and add some words save and then you see without me having
2:38 to reload in the browser I got the updates from my content.