emptygif
भाषा: हिन्दी

सभी भाषाएँ और फ़्रेमवर्क

RedwoodSDK TypeScript

RedwoodSDK के लिए TypeScript स्निपेट, जो /pixel.gif पर आने वाली रिक्वेस्ट का जवाब empty GIF से देता है। GIF स्टार्टअप पर एक ही बार डिकोड होता है।

RedwoodSDK TypeScript

इंस्टॉल
npx create-rwsdk my-app
फ़ाइल
worker.tsx
चलाएँ
npm run dev
// src/worker.tsx - a route before render() answers with its own Response
import { render, route } from 'rwsdk/router';
import { defineApp } from 'rwsdk/worker';

import { Document } from '@/app/document';
import { Home } from '@/app/pages/home';

const GIF = Uint8Array.from(atob('R0lGODlhAQABAIAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw=='), (c) => c.charCodeAt(0));

export default defineApp([
  route('/pixel.gif', () =>
    new Response(GIF, {
      headers: {
        'Content-Type': 'image/gif',
        'Content-Length': String(GIF.length),
        'Cache-Control': 'no-store',
      },
    }),
  ),
  render(Document, [route('/', Home)]),
]);

हमने यह स्निपेट चलाया और इसके लौटाए बाइट्स की तुलना की।

जाँचें

curl -sI http://localhost:8080/pixel.gif

आधिकारिक साइट: RedwoodSDK

TypeScript में और