Readme
This val is a wrapper on top of the val.town run api, improving it with additional features:
- basic auth
- content-type header in response based on url file extension
The content-type will be inferred from the filename using the mime-types library.
If you use a .html
extension, the response will be interpreted as text/html
~ $ curl -v 'https://pomdtr-run.web.val.run/pomdtr/helloWorld.html'
HTTP/1.1 200 OK
...
Content-Type: text/html; charset=utf-8
...
Hello, World!
If you switch the extension to .txt
, the content-type header switch to text/raw
.
~ $ curl -v 'https://pomdtr-run.web.val.run/pomdtr/helloWorld.txt'
HTTP/1.1 200 OK
...
Content-Type: text/plain; charset=utf-8
...
Hello, World!
The request is proxyed to the run api, so you can pass args to your vals via query params or body. See the run api docs for more details.
~ $ curl -X POST -d '{"args": ["pomdtr"]}' 'https://pomdtr-run.web.val.run/pomdtr/helloWorld.html'
...
< content-type: text/html; charset=utf-8
...
Hello, pomdtr!
Just add your val town token as the username:
curl 'https://<val-token>@pomdtr-run.web.val.run/pomdtr/privateVal.txt'
Val Town is a social website to write and deploy JavaScript.
Build APIs and schedule functions from your browser.
pomdtr-run.web.val.run
Updated: October 23, 2023
Really cool! Would be great to have an example in the README about how changing the extension changes the type. E.g. you could curl the same URL but ending in txt for a plaintext page.
Good idea!