diff --git a/README.md b/README.md index 6efc4b6..aa28cf6 100644 --- a/README.md +++ b/README.md @@ -155,6 +155,11 @@ Example: ./build.sh -u https://start.domain.tld -d static -t "STILDE - StartPage - **On mobile devices** you can open/close the input and you keyboard by a touch on the logo. +## Contrib + +I put the files I use to serve Stilde on the localhost with a python http server and systemd. You will need to correct the locations and provide a certificate. + +It's not part of the main folder because it's just a niche way to use Stilde. ---- diff --git a/contrib/serve-https.py b/contrib/serve-https.py new file mode 100644 index 0000000..e1ddedc --- /dev/null +++ b/contrib/serve-https.py @@ -0,0 +1,29 @@ +import os +import http.server +import socketserver +import ssl + +# Set the path to the directory you want to serve +directory_to_serve = os.path.expanduser('~/.local/opt/stilde') + +# Set the port for your HTTPS server +port = 1984 + +# Specify the SSL/TLS certificate and key files +certfile = os.path.expanduser('~/.ssl/MYRootCA/localhost.crt') +keyfile = os.path.expanduser('~/.ssl/MYRootCA/localhost.key') + +# Create a custom handler to use the SSL context +class MyHandler(http.server.SimpleHTTPRequestHandler): + def __init__(self, *args, **kwargs): + super().__init__(*args, directory=directory_to_serve, **kwargs) + +# Create an SSL context +ssl_context = ssl.SSLContext(ssl.PROTOCOL_TLS_SERVER) +ssl_context.load_cert_chain(certfile=certfile, keyfile=keyfile) + +# Create the HTTPS server +with socketserver.TCPServer(("127.0.1.1", port), MyHandler) as httpd: + httpd.socket = ssl_context.wrap_socket(httpd.socket, server_side=True) + print(f"Serving directory at https://127.0.1.1:{port}") + httpd.serve_forever() diff --git a/contrib/stilde.service b/contrib/stilde.service new file mode 100644 index 0000000..f42dd82 --- /dev/null +++ b/contrib/stilde.service @@ -0,0 +1,18 @@ +[Unit] +Description=Stilde startpage Web server +PartOf=graphical-session.target +After=journal.service + +[Service] +Type=simple +Restart=no +WorkingDirectory=%h/.local/opt/stilde +ExecStart=python3 %h/.local/opt/stilde/serve-https.py + +StandardOutput=journal +StandardError=journal +SyslogIdentifier=stilde +Slice=background.slice + +[Install] +WantedBy=graphical-session.target