this repo has no description smallweb.run
smallweb
4
fork

Configure Feed

Select the types of activity you want to include in your feed.

at main 59 lines 1.6 kB view raw
1async function handleRequest() { 2 const { SMALLWEB_DOMAIN, SMALLWEB_DIR } = Deno.env.toObject() 3 const entries = await Array.fromAsync(Deno.readDir(SMALLWEB_DIR)) 4 const html = /* html */` 5 <style> 6 body { 7 font-family: Arial, sans-serif; 8 margin: 0; 9 } 10 table { 11 width: 100%; 12 border-collapse: collapse; 13 } 14 th, td { 15 border: 1px solid #ddd; 16 padding: 8px; 17 text-align: left; 18 } 19 th { 20 background-color: #f2f2f2; 21 } 22 tr:nth-child(even) { 23 background-color: #f2f2f2; 24 } 25 </style> 26 <table> 27 <thead> 28 <tr> 29 <th>Name</th> 30 <th>URL</th> 31 </tr> 32 </thead> 33 <tbody> 34 ${entries.filter(entry => !entry.name.startsWith(".")).map(entry => ` 35 <tr> 36 <td>${entry.name}</td> 37 <td><a href="https://${entry.name}.${SMALLWEB_DOMAIN}">https://${entry.name}.${SMALLWEB_DOMAIN}</a></td> 38 </tr> 39 `).join('')} 40 </tbody> 41 </table> 42 ` 43 return new Response(html, { 44 headers: { 45 "content-type": "text/html" 46 } 47 }) 48} 49 50async function handleCommand() { 51 const { SMALLWEB_DIR } = Deno.env.toObject() 52 const entries = await Array.fromAsync(Deno.readDir(SMALLWEB_DIR)) 53 console.log(entries.filter(entry => !entry.name.startsWith(".")).map(entry => entry.name).join("\n")) 54} 55 56export default { 57 fetch: handleRequest, 58 run: handleCommand, 59}