Aktueller Stand
This commit is contained in:
11
backend/node_modules/@fastify/send/examples/simple.js
generated
vendored
11
backend/node_modules/@fastify/send/examples/simple.js
generated
vendored
@@ -1,14 +1,15 @@
|
||||
'use strict'
|
||||
|
||||
const http = require('http')
|
||||
const http = require('node:http')
|
||||
const send = require('..')
|
||||
const path = require('path')
|
||||
const path = require('node:path')
|
||||
|
||||
const indexPath = path.join(__dirname, 'index.html')
|
||||
|
||||
const server = http.createServer(function onRequest (req, res) {
|
||||
send(req, indexPath)
|
||||
.pipe(res)
|
||||
const server = http.createServer(async function onRequest (req, res) {
|
||||
const { statusCode, headers, stream } = await send(req, indexPath)
|
||||
res.writeHead(statusCode, headers)
|
||||
stream.pipe(res)
|
||||
})
|
||||
|
||||
server.listen(3000)
|
||||
|
||||
Reference in New Issue
Block a user