blob_adminapp.tsx19 matches
70const menuRef = useRef(null);
71const isPublic = blob.key.startsWith("__public/");
72const publicUrl = isPublic ? `${window.location.origin}/api/public/${encodeURIComponent(blob.key.slice(9))}` : null;
7374useEffect(() => {
234setLoading(true);
235try {
236const response = await fetch(`/api/blobs?prefix=${encodeKey(searchPrefix)}&limit=${limit}`);
237const data = await response.json();
238setBlobs(data);
261setBlobContentLoading(true);
262try {
263const response = await fetch(`/api/blob?key=${encodeKey(clickedBlob.key)}`);
264const content = await response.text();
265setSelectedBlob({ ...clickedBlob, key: decodeKey(clickedBlob.key) });
275const handleSave = async () => {
276try {
277await fetch(`/api/blob?key=${encodeKey(selectedBlob.key)}`, {
278method: "PUT",
279body: editContent,
287const handleDelete = async (key) => {
288try {
289await fetch(`/api/blob?key=${encodeKey(key)}`, { method: "DELETE" });
290setBlobs(blobs.filter(b => b.key !== key));
291if (selectedBlob && selectedBlob.key === key) {
304const key = `${searchPrefix}${file.name}`;
305formData.append("key", encodeKey(key));
306await fetch("/api/blob", { method: "POST", body: formData });
307const newBlob = { key, size: file.size, lastModified: new Date().toISOString() };
308setBlobs([newBlob, ...blobs]);
326try {
327const fullKey = `${searchPrefix}${key}`;
328await fetch(`/api/blob?key=${encodeKey(fullKey)}`, {
329method: "PUT",
330body: "",
341const handleDownload = async (key) => {
342try {
343const response = await fetch(`/api/blob?key=${encodeKey(key)}`);
344const blob = await response.blob();
345const url = window.URL.createObjectURL(blob);
360if (newKey && newKey !== oldKey) {
361try {
362const response = await fetch(`/api/blob?key=${encodeKey(oldKey)}`);
363const content = await response.blob();
364await fetch(`/api/blob?key=${encodeKey(newKey)}`, {
365method: "PUT",
366body: content,
367});
368await fetch(`/api/blob?key=${encodeKey(oldKey)}`, { method: "DELETE" });
369setBlobs(blobs.map(b => b.key === oldKey ? { ...b, key: newKey } : b));
370if (selectedBlob && selectedBlob.key === oldKey) {
380const newKey = `__public/${key}`;
381try {
382const response = await fetch(`/api/blob?key=${encodeKey(key)}`);
383const content = await response.blob();
384await fetch(`/api/blob?key=${encodeKey(newKey)}`, {
385method: "PUT",
386body: content,
387});
388await fetch(`/api/blob?key=${encodeKey(key)}`, { method: "DELETE" });
389setBlobs(blobs.map(b => b.key === key ? { ...b, key: newKey } : b));
390if (selectedBlob && selectedBlob.key === key) {
399const newKey = key.slice(9); // Remove "__public/" prefix
400try {
401const response = await fetch(`/api/blob?key=${encodeKey(key)}`);
402const content = await response.blob();
403await fetch(`/api/blob?key=${encodeKey(newKey)}`, {
404method: "PUT",
405body: content,
406});
407await fetch(`/api/blob?key=${encodeKey(key)}`, { method: "DELETE" });
408setBlobs(blobs.map(b => b.key === key ? { ...b, key: newKey } : b));
409if (selectedBlob && selectedBlob.key === key) {
554onClick={() =>
555copyToClipboard(
556`${window.location.origin}/api/public/${encodeURIComponent(selectedBlob.key.slice(9))}`,
557)}
558className="text-blue-400 hover:text-blue-300 text-sm"
577>
578<img
579src={`/api/blob?key=${encodeKey(selectedBlob.key)}`}
580alt="Blob content"
581className="max-w-full h-auto"
HN-fetch-callapi.tsx0 matches
1//
2interface Item {
3id: number; // The item's unique id.
4deleted: boolean; // true if the item is deleted.
5type: "job" | "stroy" | "comment" | "poll" | "pollopt"; // The type of item. One of "job", "story", "comment", "poll", or "pollopt".
openaiproxyREADME.md1 match
1# OpenAI Proxy
23This OpenAI API proxy injects Val Town's API keys. For usage documentation, check out https://www.val.town/v/std/openai
45Migrated from folder: openai/openaiproxy
openaiproxymain.tsx5 matches
1import { parseBearerString } from "https://esm.town/v/andreterron/parseBearerString";
2import { API_URL } from "https://esm.town/v/std/API_URL?v=5";
3import { OpenAIUsage } from "https://esm.town/v/std/OpenAIUsage";
4import { RateLimit } from "npm:@rlimit/http";
27const authHeader = req.headers.get("Proxy-Authorization") || req.headers.get("Authorization");
28const token = authHeader ? parseBearerString(authHeader) : undefined;
29const meRes = await fetch(`${API_URL}/v1/me`, { headers: { Authorization: `Bearer ${token}` } });
30if (!meRes.ok) {
31return new Response("Unauthorized", { status: 401 });
4344// Proxy the request
45const url = new URL("." + pathname, "https://api.openai.com");
46url.search = search;
4748const headers = new Headers(req.headers);
49headers.set("Host", url.hostname);
50headers.set("Authorization", `Bearer ${Deno.env.get("OPENAI_API_KEY")}`);
51headers.set("OpenAI-Organization", Deno.env.get("OPENAI_API_ORG"));
5253const modifiedBody = await limitFreeModel(req, user);
url-to-markdownindex.html1 match
9091// Use a CORS proxy as fallback
92const proxyUrl = `https://api.allorigins.win/get?url=${encodeURIComponent(url)}`;
93const response = await fetch(proxyUrl);
94
url-to-markdownREADME.md2 matches
49Works in all modern browsers that support:
50- ES6 modules
51- Fetch API
52- Clipboard API (for copy functionality)
53- DOMParser
1# Body Measurement System
23A computer vision application that calculates body measurements from a single photo using OpenCV and MediaPipe pose detection.
45## Features
67- Upload a person's photo
8- Automatic pose detection using MediaPipe
9- Calculate key body measurements:
10- Height
21## How it works
22231. **Pose Detection**: Uses MediaPipe to detect 33 key body landmarks
242. **Reference Scaling**: Uses known body proportions or user-provided reference measurements
253. **Anthropometric Calculations**: Applies standard body measurement formulas
44```
45โโโ backend/
46โ โโโ index.ts # Main API server
47โ โโโ pose-detection.ts # MediaPipe pose detection
48โ โโโ measurements.ts # Body measurement calculations
49โ โโโ utils.ts # Helper functions
56```
5758## API Endpoints
5960- `POST /api/measure` - Upload image and get body measurements
61- `POST /api/report` - Download measurements as text file
62- `GET /api/health` - Health check endpoint
63- `GET /api/docs` - API documentation
64- `GET /` - Serve the main application
6568This demo currently uses mock pose detection for demonstration purposes. To integrate with real pose detection:
6970### Option 1: MediaPipe (Recommended for accuracy)
71```bash
72npm install @mediapipe/pose @mediapipe/camera_utils
73```
74
Demoreal-pose-integration.ts16 matches
1// Example of how to integrate with real MediaPipe pose detection
2// This file shows how you would replace the mock pose detection with actual MediaPipe
34/*
5To use real MediaPipe pose detection, you would need to:
671. Install MediaPipe dependencies:
8- @mediapipe/pose
9- @mediapipe/camera_utils
10- @mediapipe/drawing_utils
11122. Replace the mock pose detection in pose-detection.ts with this implementation:
1314import { Pose, Results } from '@mediapipe/pose';
15import { Camera } from '@mediapipe/camera_utils';
1617export class RealPoseDetector {
22this.pose = new Pose({
23locateFile: (file) => {
24return `https://cdn.jsdelivr.net/npm/@mediapipe/pose/${file}`;
25}
26});
57this.pose.onResults((results: Results) => {
58if (results.poseLandmarks && results.poseLandmarks.length > 0) {
59// Convert MediaPipe landmarks to our format
60const landmarks = results.poseLandmarks.map(landmark => ({
61x: landmark.x,
70});
7172// Send image to MediaPipe
73this.pose.send({ image: canvas });
74};
82// For server-side processing (Node.js/Deno), you would use:
83// - @tensorflow/tfjs-node for TensorFlow.js
84// - @mediapipe/tasks-vision for MediaPipe Tasks
85// - opencv4nodejs for OpenCV
86159],
160cons: [
161"Only 17 keypoints vs MediaPipe's 33",
162"No z-coordinate",
163"Less accurate than MediaPipe"
164],
165bestFor: "Applications where speed and simplicity are more important than maximum accuracy"
185For production use, we recommend:
1861871. MediaPipe for web applications (client-side processing)
1882. TensorFlow.js PoseNet for server-side processing
1893. Combine with OpenCV for additional image preprocessing
1// Main API server for body measurement system
2import { Hono } from "https://esm.sh/hono@3.11.7";
3import { readFile, serveFile } from "https://esm.town/v/std/utils@85-main/index.ts";
28const dataScript = `<script>
29window.__INITIAL_DATA__ = {
30apiEndpoint: '/api/measure',
31maxFileSize: 10 * 1024 * 1024, // 10MB
32supportedFormats: ['image/jpeg', 'image/png', 'image/webp']
3940// Main measurement endpoint
41app.post("/api/measure", async c => {
42try {
43const body: MeasurementRequest = await c.req.json();
105106// Get measurement report as text
107app.post("/api/report", async c => {
108try {
109const body: MeasurementRequest = await c.req.json();
141142// Health check endpoint
143app.get("/api/health", c => {
144return c.json({
145status: "healthy",
149});
150151// API documentation
152app.get("/api/docs", c => {
153const docs = {
154title: "Body Measurement API",
155version: "1.0.0",
156endpoints: {
157"POST /api/measure": {
158description: "Calculate body measurements from an image",
159body: {
170}
171},
172"POST /api/report": {
173description: "Generate a text report of body measurements",
174body: "Same as /api/measure",
175response: "text/plain (measurement report)"
176},
177"GET /api/health": {
178description: "Health check endpoint",
179response: {
Demoindex.html2 matches
169};
170171const response = await fetch('/api/measure', {
172method: 'POST',
173headers: {
209};
210211const response = await fetch('/api/report', {
212method: 'POST',
213headers: {