Back to APIs list
Google Drive API examples & templates
Use these vals as a playground to view and fork Google Drive API examples and templates on Val Town. Run any example below or find templates that can be used as a pre-built solution.
imd_distrcitwise_warnings
@thejeshgn
HTTP (deprecated)
IMD Warnings Get IMD Warning for a location ( actually of the district the location belongs to). Go to the blog post below for all the details. Blog: https://thejeshgn.com/2024/09/11/simple-imd-alerts/ Credit : https://mausam.imd.gov.in/responsive/subDivisionWiseWarningGIS.php URL Format HTML - https://thejeshgn-imd_distrcitwise_warnings.web.val.run/?lat=12.9796&lon=77.5906&format=html JSON - https://thejeshgn-imd_distrcitwise_warnings.web.val.run/?lat=12.9796&lon=77.5906&format=json where lat = latitude lon = longitude format = html or json defaults If no lat or lon given, it will take bangalore's. defaults : If no format is given then it is html Examples: Bangalore, KA https://thejeshgn-imd_distrcitwise_warnings.web.val.run/?lat=12.9796&lon=77.5906 Thrissur, KL https://thejeshgn-imd_distrcitwise_warnings.web.val.run/?lat=10.527611&lon=76.214389 Lalitpur, UP https://thejeshgn-imd_distrcitwise_warnings.web.val.run/?lat=24.6936599&lon=78.412621 Vishisha, MP https://thejeshgn-imd_distrcitwise_warnings.web.val.run/?lat=23.5210259&lon=77.809569
lastlogin
@pomdtr
Script
Lastlogin Authentication for val.town Looking for an hono integration ? See @pomdtr/lastloginHono Support login in trough: Email Link QR Code Google Oauth Github Oauth Gitlab Oauth Facebook Oauth Demo You can try a demo at https://pomdtr-lastloginhonoexample.web.val.run (see @pomdtr/lastLoginHonoExample for code) Usage Wrap your http handlers in a lastlogin middleware (sessions will be persisted in the lastlogin_session table on your sqlite account). If you want to be the only one able to access your val, you can use @pomdtr/verifyUserEmail. import { lastlogin } from "https://esm.town/v/pomdtr/lastlogin";
import { verifyUserEmail } from "https://esm.town/v/pomdtr/verifyUserEmail";
export default lastlogin((req) => {
return new Response(`You are logged in as ${req.headers.get("X-LastLogin-Email")}`);
}, {
// check that the user email match your val town email
verifyEmail: verifyUserEmail
}); If you want to customize how is allowed to signup, you can set the verifyEmail option: import { lastlogin } from "https://esm.town/v/pomdtr/lastlogin";
export default lastlogin((req) => {
return new Response(`You are logged in as ${req.headers.get("X-LastLogin-Email")}`);
}, {
verifyEmail: (email) => { email == "steve@valtown" }
}); You can allow anyone to signup by returning a boolean from the verifyEmail function: import { lastlogin } from "https://esm.town/v/pomdtr/lastlogin";
export default lastlogin((req) => {
return new Response(`You are logged in as ${req.headers.get("X-LastLogin-Email")}`);
}, {
verifyEmail: (_email) => true
}); Public Routes import { lastlogin } from "https://esm.town/v/pomdtr/lastlogin";
import { verifyUserEmail } from "https://esm.town/v/pomdtr/verifyUserEmail";
export default lastlogin(() => {
return new Response("Hi!");
}, {
verifyEmail: verifyUserEmail,
public_routes: ["/", "/public/*"],
}); See the URLPattern API for reference. Logout Just redirect the user to /auth/logout
indirection
@jxnblk
HTTP
A game of riddles to play with your friends How to play To start a game, choose a 3-20 letter word. The game generates a riddle based on your word. Copy the link to share with your friends to see if they can guess the word. If they guess the word correctly, they get to pick a new word and can send you a new clue back. If they guess wrong, the next riddle is based on the word they guessed You can play with 2 or as many people as you want.
You can follow a long chain, like the game Telephone or games can branch with multiple players. TODO [ ] Reload after updating the URL to support native share sheets [ ] Incorrect state / helpers [x] Trim and lowercase guesses
sdxl
@fal
Script
SDXL (fastest) https://www.fal.ai/models/stable-diffusion-xl link to val - https://www.val.town/v/fal/sdxl import * as fal from "npm:@fal-ai/serverless-client";
const result = await fal.subscribe("fal-ai/fast-sdxl", {
input: {
prompt: "photo of a rhino dressed suit and tie sitting at a table in a bar with a bar stools, award winning photography, Elke vogelsang"
},
logs: true,
onQueueUpdate: (update) => {
if (update.status === "IN_PROGRESS") {
update.logs.map((log) => log.message).forEach(console.log);
}
},
});