17import { html } from "https://esm.town/v/stevekrouse/html?v=5";
1819export async function examplePost(req: Request) {
20const { author, name } = extractValInfo(import.meta.url);
21return html(await article(author, name));
emailRandomJokemain.tsx1 match
23// Fetches a random joke.
4async function fetchRandomJoke() {
5const response = await fetch(
6"https://official-joke-api.appspot.com/random_joke",
emailRandomJokemain.tsx1 match
23// Fetches a random joke.
4async function fetchRandomJoke() {
5const response = await fetch(
6"https://official-joke-api.appspot.com/random_joke",
emailRandomJokemain.tsx1 match
23// Fetches a random joke.
4async function fetchRandomJoke() {
5const response = await fetch(
6"https://official-joke-api.appspot.com/random_joke",
2import { set } from "https://esm.town/v/std/set?v=11";
34export async function setTemp(temp: Request) {
5const currentDate = new Date();
6const timestamp = currentDate.getTime();
1export async function untitled_amethystStork(request: Request): Promise<Response> {
2return Response.json({ ok: true })
3}
1# Render html by tagged templates
23You can use this simple function to compose components, and you can also format the content within html`` elegantly in VSCode.
45## Example
1export async function lableaks(request: Request): Promise<Response> {
2// Define the HTML content
3const htmlContent = `<!DOCTYPE html>
8<title>WebSocket Example</title>
9<script>
10document.addEventListener("DOMContentLoaded", function () {
11var ws = new WebSocket("wss://cjs-mac-mini.tail73f30.ts.net");
12var textContainer = document.getElementById("text");
17var id; // This will hold the id from the server response
18
19ws.onopen = function () {
20console.log("Connected to the WebSocket server");
21};
23var statusSpan = document.getElementById("status");
24
25ws.onmessage = function (event) {
26var data = JSON.parse(event.data);
27id = data.id; // Assuming the id is in the server response
43};
44
45function sendChoice(choice) {
46console.log("Button " + choice + " clicked");
47ws.send(
52})
53);
54// setTimeout(function () {
55// location.reload();
56// }, 4000);
57}
58
59buttonA.addEventListener("click", function () {
60sendChoice(1);
61});
62
63buttonB.addEventListener("click", function () {
64sendChoice(2);
65});
66
67ws.onclose = function () {
68console.log("Disconnected from the WebSocket server");
69};
70
71ws.onerror = function (error) {
72console.log("WebSocket Error: " + error);
73};
aqiPushGotifymain.tsx1 match
4import process from "node:process";
56export async function aqiPushGotify(interval: Interval) {
7const location = "Portland, Oregon"; // <-- change to place, city, or zip code
8const data = await easyAQI({ location });
emailRandomJokemain.tsx1 match
23// Fetches a random joke.
4async function fetchRandomJoke() {
5const response = await fetch(
6"https://official-joke-api.appspot.com/random_joke",