How To Set Up A Photo Library With Raspberry Pi
How To Set Up A Photo Library With Raspberry Pi
Raspberry Pi
/etc/nginx/sites-enable/server
{
listen 80;
server_name _;
return 301 https://$host$request_uri;a
}
server {
listen 443;
server_name _;
root /home/pi/server;
index index.php;
location / {
try_files $uri $uri/ =404;
}
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/var/run/php/php7.3-fpm.sock;
}
location ~ /.well-known {
allow all;
}
}
/home/pi/server/index.php
<!DOCTYPE html>
<html>
<head>
<title>Welcome to My Photo Library!</title>
<style>
body {
width: auto;
margin-left: 2em;
margin-right: 2em;
font-family: Garamond, serif;
}
* {
margin: 0;
padding: 0;
}
img {
image-orientation: from-image;
}
.imgbox {
display: grid;
height: 100%;
}
.center-fit {
max-width: 100%;
max-height: 100vh;
margin: auto;
}
li {
list-style-type:none;
margin-right:10px;
margin-bottom:10px;
float:left;
}
</style>
</head>
<body>
<h1>Welcome to My Photo Library!</h1>
<div class="imgbox">
<ul>
<?php
$handle = opendir(dirname(realpath(__FILE__)).'/image/');
while($file = readdir($handle)){
if($file !== '.' && $file !== '..' && $file !== '.DS_Store')
{
echo '<img class="center-fit" src="image/'.$file.'">';
}
}
?>
</ul>
</div>
</body>
</html>