Last active
August 9, 2025 10:49
-
-
Save ryanflorence/907ed9e9358944b309905ab831140032 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
| import { createServer } from "http"; | |
| createServer(async (req, res) => { | |
| if (req.url === "/app.js") { | |
| res.setHeader("Content-Type", "application/javascript; charset=UTF-8"); | |
| res.setHeader("Cache-Control", "max-age=10"); | |
| res.write(`console.log("lol")`); | |
| res.end(); | |
| return; | |
| } | |
| if (req.url === "/app.css") { | |
| res.setHeader("Content-Type", "text/css; charset=UTF-8"); | |
| res.setHeader("Cache-Control", "max-age=10"); | |
| res.write(`body { font-family: system-ui }`); | |
| res.end(); | |
| return; | |
| } | |
| res.setHeader( | |
| "Link", | |
| "</app.js>; rel=modulepreload, </app.css>; rel=preload; as=style" | |
| ); | |
| res.setHeader("Content-Type", "text/html; charset=utf-8"); | |
| res.write(` | |
| <!doctype html> | |
| <html> | |
| <head> | |
| <title>Okay</title> | |
| `); | |
| await new Promise((res) => setTimeout(res, 5000)); | |
| res.write(` | |
| <link rel="stylesheet" href="/app.css" /> | |
| </head> | |
| <body> | |
| <p>(are the assets loading?)</p> | |
| <h1>LOL I'm done</h1> | |
| <script type="module" src="/app.js"></script> | |
| </body> | |
| </html> | |
| `); | |
| res.end(); | |
| }).listen(8080); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
mechatroner.rainbow-csv