Go to file
2024-09-29 09:14:16 -07:00
src I forgot what I did because I have been asleep for 16 hours 2024-09-29 09:14:16 -07:00
.gitignore add logging, update readme 2024-08-14 14:00:27 -07:00
README.md fix readme 2024-08-14 14:02:13 -07:00
shell.nix I forgot what I did because I have been asleep for 16 hours 2024-09-29 09:14:16 -07:00

sludge: webthing for natalieee.net

it rhymes with kludge.

config

ssl-key: ./key.pem
ssl-cert: ./cert.pem
http-port: 5000 
https-port: # 5001
file-dir: 'site'

ssl-{cert,key} are self explanatory. if the value of https? port is commented or not present, it will not run the https? server on that port. file-dir is where the files for the site can be found. the above config is the config for the local version of my website, which is used for testing. it runs an http server on 5000, but no https server.

serving files

  • src/lib/router.py has the routing config for my website in it. it is easy to modify to your usecase.
  • src/lib/patchers.py has the patching config for my website in it. it is also easy to modify.

dynamic content

embedded bash scripting

sludge has support for inline bash inside of html documents.
ex:

<p>lorem ipsum $[echo foo]</p>

would resolve to

<p>lorem ipsum foo</p>

variables in html

in addition to the above, you can have variables embedded in html.

<p>lorem ipsum {aoeu}</p> 

would normally resolve to

<p>lorem ipsum {aoeu}</p> 

however, if we assume that this text is in a file foo.html, then we can serve that file such that

parse_file('./foo.html', dict(aoeu='foo'))

in which case it would resolve to

<p>lorem ipsum foo</p>

in practice, this may be seen here:

Route(
    lambda path: os.path.isdir('.' + path.path), 
    [Method.GET],
    lambda request, *_: Response(
        ResponseCode.OK, 
        {'Content-Type': 'text/html'},
        parse_file('./dir_index.html', dict(path='.' + request.path.path)).encode('utf-8')
    )
)