added index
This commit is contained in:
parent
756221a4b1
commit
a735d06185
File diff suppressed because one or more lines are too long
|
@ -0,0 +1,37 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>dzserver</title>
|
||||
<style>
|
||||
@import url('https://fonts.googleapis.com/css2?family=Roboto:wght@300&display=swap');
|
||||
body {
|
||||
background-color: #474747;
|
||||
}
|
||||
p, h1, h2, a {
|
||||
color: #ffffff;
|
||||
font-family: 'Roboto', sans-serif;
|
||||
text-align: center;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<h1>dzserver</h1>
|
||||
<h2><a href="https://git.freezer.life/uhwot/dzserver">source code</a></h2>
|
||||
<br>
|
||||
|
||||
<p>how 2 use:</p>
|
||||
<p><b>/track/<id></b></p>
|
||||
<p><b>/album/<id></b></p>
|
||||
<p><b>/playlist/<id></b></p>
|
||||
<br>
|
||||
|
||||
<p>params are:</p>
|
||||
<p><b>t: tagging</b>, boolean</p>
|
||||
<p><b>f: format</b>, can be one of these:</p>
|
||||
<p>aac_96, 64, 128, 320, ra1, ra2, ra3, sbc_256, misc</p>
|
||||
<p>available formats depend on the track</p>
|
||||
</body>
|
||||
</html>
|
11
index.js
11
index.js
|
@ -39,11 +39,11 @@ async function handler(type, request) {
|
|||
} else {
|
||||
format = format.toLowerCase()
|
||||
if (format_string_to_num[format] === undefined) {
|
||||
index = Object.values(format_string_to_num).indexOf(format)
|
||||
if (index === -1) {
|
||||
html = Object.values(format_string_to_num).indexOf(format)
|
||||
if (html === -1) {
|
||||
return new Response('Invalid format', { status: 400, headers: { 'content-type': 'text/plain' } })
|
||||
}
|
||||
format = Object.keys(format_string_to_num)[index]
|
||||
format = Object.keys(format_string_to_num)[html]
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -231,8 +231,13 @@ async function m3u8(type, id, format, access_token, tagging, host) {
|
|||
return new Response(list, { status: 200, headers: { 'content-type': 'audio/mpegurl' } })
|
||||
}
|
||||
|
||||
async function indexHandler() {
|
||||
return new Response(require('./index.html'), { status: 200, headers: { 'content-type': 'text/html' } })
|
||||
}
|
||||
|
||||
async function handleRequest(request) {
|
||||
const r = new Router()
|
||||
r.get('/', () => indexHandler())
|
||||
r.get('/track/-?\\d+', () => handler('track', request))
|
||||
r.get('/album/\\d+', () => handler('album', request))
|
||||
r.get('/playlist/\\d+', () => handler('playlist', request))
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -11,6 +11,7 @@
|
|||
"license": "MIT",
|
||||
"devDependencies": {
|
||||
"@wasm-tool/wasm-pack-plugin": "^1.5.0",
|
||||
"html-loader": "^1.3.2",
|
||||
"prettier": "^1.17.0"
|
||||
},
|
||||
"dependencies": {
|
||||
|
|
|
@ -9,5 +9,13 @@ module.exports = {
|
|||
new WasmPackPlugin({
|
||||
crateDirectory: __dirname,
|
||||
}),
|
||||
]
|
||||
],
|
||||
module: {
|
||||
rules: [
|
||||
{
|
||||
test: /\.html$/i,
|
||||
loader: 'html-loader'
|
||||
}
|
||||
]
|
||||
}
|
||||
};
|
Loading…
Reference in New Issue