import { createServer } from 'http'
import QRCode from 'qrcode'
createServer(function handler (req, res) {
const url = new URL(req.url, 'http://localhost:8080')
const data = url.searchParams.get('data')
if (!data) {
res.writeHead(200, {'Content-Type': 'text/html'})
return res.end(`
To use this app you need to set the data querystrin
Try for example /?data=hello
`)
}
res.writeHead(200, { 'Content-Type': 'image/png' })
QRCode.toFileStream(res, data, { width: 300 })
}).listen(8080)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
import { createServer } from 'http'
import QRCode from 'qrcode'
1
2
3
createServer(function handler (req, res) {
4
const url = new URL(req.url, 'http://localhost:8080')
5
const data = url.searchParams.get('data')
6
if (!data) {
7
res.writeHead(200, {'Content-Type': 'text/html'})
8
return res.end(`
9
10
To use this app you need to set the data querystrin
11
Try for example /?data=hello
12
13
`)
14
}
15
res.writeHead(200, { 'Content-Type': 'image/png' })
16
QRCode.toFileStream(res, data, { width: 300 })
17
}).listen(8080)
18
createServer(function handler (req, res) {
}).listen(8080)
import { createServer } from 'http'
1
import QRCode from 'qrcode'
2
3
4
const url = new URL(req.url, 'http://localhost:8080')
5
const data = url.searchParams.get('data')
6
if (!data) {
7
res.writeHead(200, {'Content-Type': 'text/html'})
8
return res.end(`
9
10
To use this app you need to set the data querystrin
11
Try for example /?data=hello
12
13
`)
14
}
15
res.writeHead(200, { 'Content-Type': 'image/png' })
16
QRCode.toFileStream(res, data, { width: 300 })
17
18
const url = new URL(req.url, 'http://localhost:8080')
const data = url.searchParams.get('data')
import { createServer } from 'http'
1
import QRCode from 'qrcode'
2
3
createServer(function handler (req, res) {
4
5
6
if (!data) {
7
res.writeHead(200, {'Content-Type': 'text/html'})
8
return res.end(`
9
10
To use this app you need to set the data querystrin
11
Try for example /?data=hello
12
13
`)
14
}
15
res.writeHead(200, { 'Content-Type': 'image/png' })
16
QRCode.toFileStream(res, data, { width: 300 })
17
}).listen(8080)
18
if (!data) {
res.writeHead(200, {'Content-Type': 'text/html'})
return res.end(`
To use this app you need to set the data querystrin
Try for example /?data=hello
`)
}
import { createServer } from 'http'
1
import QRCode from 'qrcode'
2
3
createServer(function handler (req, res) {
4
const url = new URL(req.url, 'http://localhost:8080')
5
const data = url.searchParams.get('data')
6
7
8
9
10
11
12
13
14
15
res.writeHead(200, { 'Content-Type': 'image/png' })
16
QRCode.toFileStream(res, data, { width: 300 })
17
}).listen(8080)
18
res.writeHead(200, { 'Content-Type': 'image/png' })
QRCode.toFileStream(res, data, { width: 300 })
import { createServer } from 'http'
1
import QRCode from 'qrcode'
2
3
createServer(function handler (req, res) {
4
const url = new URL(req.url, 'http://localhost:8080')
5
const data = url.searchParams.get('data')
6
if (!data) {
7
res.writeHead(200, {'Content-Type': 'text/html'})
8
return res.end(`
9
10
To use this app you need to set the data querystrin
11
Try for example /?data=hello
12
13
`)
14
}
15
16
17
}).listen(8080)
18
import { createServer } from 'http'
import QRCode from 'qrcode'
createServer(function handler (req, res) {
const url = new URL(req.url, 'http://localhost:8080')
const data = url.searchParams.get('data')
if (!data) {
res.writeHead(200, {'Content-Type': 'text/html'})
return res.end(`
To use this app you need to set the data querystrin
Try for example /?data=hello
`)
}
res.writeHead(200, { 'Content-Type': 'image/png' })
QRCode.toFileStream(res, data, { width: 300 })
}).listen(8080)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
@loige
8