Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions bin/serve.js
Original file line number Diff line number Diff line change
Expand Up @@ -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}`)
}
}
}

Expand Down Expand Up @@ -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 || ''
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down