Skip to content

Commit

Permalink
update website to pass query params
Browse files Browse the repository at this point in the history
  • Loading branch information
pomdtr committed Feb 12, 2024
1 parent 626afdd commit c6cc0f6
Showing 1 changed file with 20 additions and 2 deletions.
22 changes: 20 additions & 2 deletions website/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,25 @@
</style>
</head>
<body>
<iframe src="http://localhost:9999"></iframe>
<script type="module">
try {
const params = new URLSearchParams(window.location.search);
const port = params.get("port") || 9999;

const base = `http://localhost:${port}`;
const resp = await fetch(`${base}/ping`);
if (!resp.ok) {
throw new Error("Server not found");
}

params.delete("port");
const iframe = document.createElement("iframe");
iframe.src = `${base}/?${params}`;
document.body.appendChild(iframe);
iframe.focus();
} catch (e) {
window.location.replace("https://github.com/pomdtr/tweety");
}
</script>
</body>
</html>
,

0 comments on commit c6cc0f6

Please sign in to comment.