hapi JavaScript
hapi ਲਈ JavaScript ਸਨਿੱਪਟ, ਜੋ /pixel.gif ਦੀਆਂ ਬੇਨਤੀਆਂ ਦਾ ਜਵਾਬ ਖਾਲੀ GIF ਨਾਲ ਦਿੰਦਾ ਹੈ; GIF ਸ਼ੁਰੂਆਤ ’ਤੇ ਇੱਕ ਵਾਰ ਡੀਕੋਡ ਹੁੰਦੀ ਹੈ।
hapi JavaScript
import Hapi from '@hapi/hapi';
const GIF = Buffer.from('R0lGODlhAQABAIAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==', 'base64');
const server = Hapi.server({ port: 8080 });
server.route({
method: 'GET',
path: '/pixel.gif',
handler: (request, h) =>
h.response(GIF).type('image/gif').header('Cache-Control', 'no-store'),
});
await server.start();
ਅਸੀਂ ਇਹ ਸਨਿੱਪਟ ਚਲਾਇਆ ਅਤੇ ਇਸ ਵੱਲੋਂ ਵਾਪਸ ਕੀਤੀਆਂ ਬਾਈਟਾਂ ਦੀ ਤੁਲਨਾ ਕੀਤੀ।
ਜਾਂਚੋ
curl -sI http://localhost:8080/pixel.gif
JavaScript ਵਿੱਚ ਹੋਰ
- Fastify
- Express
- Node.js standard library (node:http)
- Koa
- AWS Lambda (Node.js)
- AWS Lambda@Edge (CloudFront)
- Google Cloud Run functions (Node.js)
- Firebase Cloud Functions + Hosting
- Azure Functions (Node.js v4 model)
- Fastly Compute (JavaScript)
- nginx JavaScript (njs)
- Node.js one-liner
- Bun one-liner
- React component (JSX)