-
-
Save dom96/eb2ae290d1f79233b330bccfd28437f4 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var data: array[5, seq[string]] | |
| proc refreshMensaData() {.async.} = | |
| while true: | |
| data.fill(@[]) | |
| var client = newAsyncHttpClient() | |
| var thisweek = await client.getContent("target.url.example.com") | |
| #[ here happens some stuff ]# | |
| data[0].add(thisWeek.parseHtml()) # Guessing here | |
| # timeout in seconds, i'm guessing you want to run this multiple times | |
| await sleepAsync(10000) | |
| when isMainModule: | |
| asyncCheck refreshMensaData() | |
| # serve the data | |
| var server = newAsyncHttpServer() | |
| proc cb(req: Request) {.async.} = | |
| await req.respond(Http200, #[either html or json ]# )) | |
| waitFor server.serve(Port(80), cb) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment