Show HN: I made a pointless button website Posted by qbrught on Monday June 24, 2024 @12:48PM from the show-hn dept. https://obscurebutton.com/ All you can do is press a button. That's it, nothing else. ( 4 comments | on HN )
```js const config = { sleep: 10, max_requests: 20, log_time: 100, };
async function sleep(ms) { return new Promise((res) => setTimeout(res, ms)); }
async function click() { const res = await fetch("https://obscurebutton.com/api/clicks", { headers: { "content-type": "application/json", }, body: JSON.stringify({ increment: 10 }), method: "POST", });
}void (async function main() { let countOld = 0; let countNew = 0; let activeReqs = 0;
})(); ```Also in the future, do some input validation. Removing the `content-type` header causes a 502 internal server error to be returned.
do I win?
```go func main() { client := &http.Client{}
// Launch 100 goroutines for i := 0; i < 100; i++ { go func() { for { err := sendRequest(client) if err != nil { time.Sleep(time.Millisecond * 100) } } }() } }
```