diff --git a/index.html b/index.html new file mode 100755 index 0000000..48e7bfb --- /dev/null +++ b/index.html @@ -0,0 +1,27 @@ + + + +Welcome to telescopium + + + +

Welcome to telescopium!

+

This is shoofle's time lapse camera computer for the pear house backyard. It should take a picture daily and hold onto them, eventually compiling them into a timelapse automatically.

+ +

Please contact shoofle with any feature requests or questions.

+ +

The latest image from the camera is this:

+ + +

The full catalog of still images should be seen at http://telescopium.local/stills/.

+ + diff --git a/take_a_still.py b/take_a_still.py index d61c4da..14aa633 100644 --- a/take_a_still.py +++ b/take_a_still.py @@ -1,7 +1,30 @@ #!/bin/python3 import os -import subprocess +import shutil +from bs4 import BeautifulSoup -filename = os.popen("date +%+4Y-%m-%d-%Hh%Mm.jpg").read() +index_filename = "/var/www/html/index.html" -os.system("libcamera-jpeg -o /var/www/html/stills/{}".format(filename)) +# If the index is not present in /var/www/html, then we should restore it from the copy we've got. +if not os.path.exists(index_filename): + shutil.copy("index.html", index_filename) + print("The index was lost, so we've restored it.") + +# take a picture into the stills folder +filename = "/stills/" + os.popen("date +%+4Y-%m-%d-%Hh%Mm.jpg").read() + +os.system("libcamera-jpeg -o /var/www/html" + filename) + +#make sure that the index shows the latest one + +soup = None + +with open(index_filename, "r") as the_file: + soup = BeautifulSoup(the_file, features="html.parser") + + latest_image = soup.find(id="latest") + + latest_image['src'] = filename + +with open(index_filename, "w") as the_file: + the_file.write(str(soup))