/
quasar
/
websockets-training
Обзор
Документация
Войти
/
quasar
/
websockets-training
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
src/http_server/index.js
17 строк
539 B
Andrei Auchynnikau
[fix] linter fix
16 июн 2022, 13:14
16 июн 2022, 13:14
634dc60
Код
Авторство
О чём код?
import * as fs from 'fs'; import * as path from 'path'; import * as http from 'http'; export const httpServer = http.createServer(function (req, res) { const __dirname = path.resolve(path.dirname('')); const file_path = __dirname + (req.url === '/' ? '/front/index.html' : '/front' + req.url); fs.readFile(file_path, function (err, data) { if (err) { res.writeHead(404); res.end(JSON.stringify(err)); return; } res.writeHead(200); res.end(data); }); });