Static Sites with Sphinx and Markdown Transcripts
Chapter: Setup
Lecture: Live reload

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


Talk Python's Mastodon Michael Kennedy's Mastodon