diff --git a/bin/serve.js b/bin/serve.js index 8b477d4d..8e1295a6 100644 --- a/bin/serve.js +++ b/bin/serve.js @@ -57,10 +57,13 @@ export async function serve(serveDirectory, key) { } } console.log(`hyperparam server running on http://localhost:${port}`) - if (!key) openUrl(`http://localhost:${port}`) - else { - key = encodeURIComponent(key) - openUrl(`http://localhost:${port}/files?key=${key}`) + const isDev = process.env.NODE_ENV === 'development' + if (!isDev) { + if (!key) openUrl(`http://localhost:${port}`) + else { + key = encodeURIComponent(key) + openUrl(`http://localhost:${port}/files?key=${key}`) + } } } @@ -91,15 +94,12 @@ function handleRequest(req, serveDirectory) { } else if (pathname.startsWith('/assets/') || pathname.startsWith('/favicon') ) { // serve static files return handleStatic(`${hyperparamPath}/dist${pathname}`) - // else if (pathname.startsWith('/public/')) { - // // serve static files - // return handleStatic(`${hyperparamPath}${pathname.replace(/^(\/public).*/, '/dist')}`) } else if (serveDirectory && pathname === '/api/store/list') { // serve file list const prefix = parsedUrl.query.prefix || '' if (Array.isArray(prefix)) return { status: 400, content: 'bad request' } - const perfixPath = `${serveDirectory}/${decodeURIComponent(prefix)}` - return handleListing(perfixPath) + const prefixPath = `${serveDirectory}/${decodeURIComponent(prefix)}` + return handleListing(prefixPath) } else if (serveDirectory && pathname === '/api/store/get') { // serve file content const key = parsedUrl.query.key || '' diff --git a/package.json b/package.json index b638c228..5a888f74 100644 --- a/package.json +++ b/package.json @@ -43,8 +43,8 @@ "url": "run-p -l watch:ts watch:vite watch:url", "watch:ts": "tsc --watch", "watch:vite": "vite build --watch", - "watch:serve": "nodemon bin/cli.js", - "watch:url": "nodemon bin/cli.js https://hyperparam.blob.core.windows.net/hyperparam/starcoderdata-js-00000-of-00065.parquet" + "watch:serve": "NODE_ENV=development nodemon bin/cli.js", + "watch:url": "NODE_ENV=development nodemon bin/cli.js https://hyperparam.blob.core.windows.net/hyperparam/starcoderdata-js-00000-of-00065.parquet" }, "dependencies": { "hightable": "0.12.1",