Skip to content

Commit

Permalink
d
Browse files Browse the repository at this point in the history
  • Loading branch information
pcarrier committed Apr 2, 2024
1 parent 776e1cc commit 60d7cb3
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
* [Exposing services](#exposing-services)
* [Sharing files](#sharing-files)
* [`echo`](#echo)
* [`d`](#d)
* [Finding my IP](#finding-my-ip)

## Exposing services
Expand Down Expand Up @@ -112,6 +113,10 @@ Content-Type: application/json
{"a":42}
```

## `d`

Embed a page in the URL itself, in its client-only side. [Example](https://srv.us/d#%3Ch1%3EDemo%3C/h1%3E), [original idea](https://news.ycombinator.com/item?id=39905866).

## Finding my IP

Please take a look at [ident.me](https://api.ident.me).
5 changes: 5 additions & 0 deletions backend/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,11 @@ func (s *server) serveRoot(https *tls.Conn) error {
}
_, _ = https.Write([]byte(fmt.Sprintf("HTTP/1.1 200 OK\r\nContent-Type: %s\r\n\r\n", ct)))
_, _ = io.Copy(https, req.Body)
} else if req.URL.Path == "/d" {
defer func() {
_ = req.Body.Close()
}()
_, _ = https.Write([]byte("HTTP/1.1 200 OK\r\nContent-Type: text/html\r\n\r\n<html><head><script>document.body.innerHTML = decodeURI(window.location.hash.substring(1))</script></head></html>"))
} else if req.Method == "POST" {
defer func() {
_ = req.Body.Close()
Expand Down

0 comments on commit 60d7cb3

Please sign in to comment.