3import { DATABASE_TABLENAME } from "./constants";
45// export async function getImages(type: string, count: number): Promise<string[]> {
6// // Query to select random rows of the specified type
7// const result = await sqlite.execute(
16// );
1718// let images: string[] = [];
19// for (const row of result.rows) {
20// // console.log("row", row);
21// // const blobUrl = await blob.get(row["path"] as string);
22// images.push(row["path"] as string);
23// }
2425// return images;
26// }
2728export async function getImages(typeCountMap: Record<string, number>): Promise<Array<string>> {
29const params: (string | number)[] = [];
304142console.log(
43await getImages({
44"image": 10,
45"gif": 5,
46}),
7const [uploadStatus, setUploadStatus] = useState<string>("Drag and drop files here");
8const [fileUrl, setFileUrl] = useState<string | null>(null);
9const [imageType, setImageType] = useState<string>("image");
10const urlInputRef = useRef<HTMLInputElement>(null);
112930// Validate file type
31if (!["image/jpeg", "image/gif", "image/png"].includes(file.type)) {
32setUploadStatus("Only JPG, GIF, and PNG files are allowed");
33return;
36const formData = new FormData();
37formData.append("file", file);
38formData.append("type", imageType);
3940fetch("/upload", {
52});
53}
54}, [imageType]);
5556const handleDragOver = useCallback((event: React.DragEvent<HTMLDivElement>) => {
77<p>{uploadStatus}</p>
78<select
79value={imageType}
80onChange={(e) => setImageType(e.target.value)}
81style={{
82width: "100%",
85}}
86>
87<option value="image">Image</option>
88<option value="gif">GIF</option>
89<option value="stock_image">Stock Image</option>
90</select>
91<div
97}}
98>
99Drag and drop an image here
100</div>
101{fileUrl && (
146}}
147>
148View Image
149</a>
150</div>
167const formData = await request.formData();
168const file = formData.get("file") as File;
169const imageType = formData.get("type") as string;
170171if (!file) {
204await sqlite.execute(
205`INSERT INTO ${DATABASE_TABLENAME} (type, path) VALUES (?, ?)`,
206[imageType, publicUrl],
207);
208211url: publicUrl,
212filename: filename,
213type: imageType,
214}),
215{
223<html>
224<head>
225<title>Image Upload</title>
226<style>${css}</style>
227</head>
valentines_day_card_generatorindex5 matches
1import { getImages } from "./get_images";
23export default async function server(request: Request): Promise<Response> {
4const url = new URL(request.url);
5if (request.method === "GET" && url.pathname === "/image") {
6const params = url.searchParams;
714console.log("typecountmpap", typeCountMap);
1516const imageUrls = await getImages(typeCountMap);
1718return new Response(
19JSON.stringify({
20urls: imageUrls,
21}),
22{
32<html>
33<head>
34<title>Random Image Placement</title>
35<meta name="viewport" content="width=device-width, initial-scale=1">
36<style>
multiplayerCirclesREADME.md1 match
3Move circles around. State is synced with the server. Open a window in another tab and watch the circles update as you move them .
45
6
invoiceMakerAppmain.tsx1 match
195if (logoData) {
196return new Response(logoData, {
197headers: { "Content-Type": "image/png" },
198});
199}
cerebras_codermain.tsx1 match
1165<meta property="og:description" content="Turn your ideas into fully functional apps in less than a second – powered by Llama3.3-70b on Cerebras's super-fast wafer chips. Code is 100% open-source, hosted on Val Town."">
1166<meta property="og:type" content="website">
1167<meta property="og:image" content="https://stevekrouse-blob_admin.web.val.run/api/public/CerebrasCoderOG.jpg">
1168
1169
1165<meta property="og:description" content="Turn your ideas into fully functional apps in less than a second – powered by Llama3.3-70b on Cerebras's super-fast wafer chips. Code is 100% open-source, hosted on Val Town."">
1166<meta property="og:type" content="website">
1167<meta property="og:image" content="https://stevekrouse-blob_admin.web.val.run/api/public/CerebrasCoderOG.jpg">
1168
1169
isMyWebsiteDownREADME.md1 match
89<div align="center">
10<img src="https://imagedelivery.net/iHX6Ovru0O7AjmyT5yZRoA/67a1d35e-c37c-41a4-0e5a-03a9ba585d00/public" width="500px"/>
11</div>
status_migratedREADME.md1 match
45<div align="center">
6<img src="https://imagedelivery.net/iHX6Ovru0O7AjmyT5yZRoA/67a1d35e-c37c-41a4-0e5a-03a9ba585d00/public" width="700px"/>
7</div>
youthfulLimeAntlionREADME.md1 match
89<div align="center">
10<img src="https://imagedelivery.net/iHX6Ovru0O7AjmyT5yZRoA/67a1d35e-c37c-41a4-0e5a-03a9ba585d00/public" width="500px"/>
11</div>