From f7d0a106b7101675e5537d124833431f0ae0a36b Mon Sep 17 00:00:00 2001 From: yutent Date: Tue, 2 Jan 2024 17:11:14 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E9=85=8D=E7=BD=AE=E6=96=87?= =?UTF-8?q?=E4=BB=B6=E5=8F=98=E5=8C=96=E8=87=AA=E5=8A=A8=E9=87=8D=E5=90=AF?= =?UTF-8?q?=E6=9C=8D=E5=8A=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- index.js | 45 ++++++++++++++++++++++++++++----------------- package.json | 6 +++--- test/.httpserver | 5 +++-- 3 files changed, 34 insertions(+), 22 deletions(-) diff --git a/index.js b/index.js index e4e7998..ec44e28 100644 --- a/index.js +++ b/index.js @@ -5,14 +5,14 @@ */ const vsc = require('vscode') -const { join } = require('path') +const { join, basename } = require('path') const { parse } = require('url') const http = require('http') const fs = require('iofs') const { WebSocketServer } = require('ws') -const std = vsc.window.createOutputChannel('http.server') const decode = decodeURIComponent +const statItem = vsc.window.createStatusBarItem(vsc.StatusBarAlignment.Left, 0) const MIME_TYPES = { html: 'text/html;charset=utf-8', @@ -49,6 +49,8 @@ const COMMON_HEADERS = { 'X-Powered-By': 'VS Code simple.http' } +const CONFIG_FILE = '.httpserver' + MIME_TYPES.htm = MIME_TYPES.html MIME_TYPES.jpeg = MIME_TYPES.jpg MIME_TYPES.tif = MIME_TYPES.tiff @@ -57,13 +59,9 @@ let root let enabled = false let port = 23333 let baseUrl = 'http://127.0.0.1:' + port +let server let ws = null -std.out = function (...args) { - std.appendLine('[simple.http]: ' + args.join(' ')) - // console.log('[simple.http]: ' + args.join(' ')) -} - const HMR_SCRIPT = `