Val Town is a collaborative website to build and scale JavaScript apps.
Deploy APIs, crons, & store data – all from the browser, and deployed in miliseconds.
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'