the latest picture is always added to the index, the index is restored if necessary, and generally this is in a good state for physical work to proceed.
parent
e2eac258d7
commit
9abdff9ebe
@ -0,0 +1,27 @@ |
|||||||
|
<!DOCTYPE html> |
||||||
|
<html> |
||||||
|
<head> |
||||||
|
<title>Welcome to telescopium</title> |
||||||
|
<style> |
||||||
|
body { |
||||||
|
width: 35em; |
||||||
|
margin: 0 auto; |
||||||
|
font-family: Tahoma, Verdana, Arial, sans-serif; |
||||||
|
} |
||||||
|
#latest-still { |
||||||
|
width: 100%; |
||||||
|
} |
||||||
|
</style> |
||||||
|
</head> |
||||||
|
<body> |
||||||
|
<h1>Welcome to telescopium!</h1> |
||||||
|
<p>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.</p> |
||||||
|
|
||||||
|
<p>Please contact shoofle with any feature requests or questions.</p> |
||||||
|
|
||||||
|
<p>The latest image from the camera is this:</p> |
||||||
|
<img id="latest" src="/stills/test.jpg"/> |
||||||
|
|
||||||
|
<p>The full catalog of still images should be seen at <a href="/stills/">http://telescopium.local/stills/</a>.</p> |
||||||
|
</body> |
||||||
|
</html> |
@ -1,7 +1,30 @@ |
|||||||
#!/bin/python3 |
#!/bin/python3 |
||||||
import os |
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)) |
||||||
|
Loading…
Reference in new issue