|
@@ -45,11 +45,16 @@ app.post('/submit', function (req, res) {
|
|
|
|
|
|
res.header("Access-Control-Allow-Origin", "*");
|
|
|
|
|
|
-
|
|
|
+ let albumCover = null;
|
|
|
try {
|
|
|
fetch(req.body.file).then(res => {
|
|
|
res.arrayBuffer().then(r => fs.writeFileSync("./" + uuid, Buffer.from(r)));
|
|
|
})
|
|
|
+ fetch(req.body.albumCover).then(res=>{
|
|
|
+ res.arrayBuffer().then(r=>{
|
|
|
+ albumCover = r
|
|
|
+ })
|
|
|
+ })
|
|
|
|
|
|
res.end("api_success");
|
|
|
} catch (err) {
|
|
@@ -97,7 +102,7 @@ app.post('/submit', function (req, res) {
|
|
|
onData: callback, onError: errcb
|
|
|
}).then(() => {
|
|
|
|
|
|
- db.execute(("INSERT INTO instrunet_entry (uuid, song_name, album_name, link_to, databinary, artist,kind) VALUES (?,?,?,?,?,?,?)"), [uuid, req.body.name, req.body.albumName, req.body.link, fs.readFileSync(kind_of[1]), req.body.artist, req.body.kind])
|
|
|
+ db.execute(("INSERT INTO instrunet_entry (uuid, song_name, album_name, link_to, databinary, artist,kind, albumcover) VALUES (?,?,?,?,?,?,?,?)"), [uuid, req.body.name, req.body.albumName, req.body.link, fs.readFileSync(kind_of[1]), req.body.artist, req.body.kind, albumCover])
|
|
|
db.unprepare(() => {
|
|
|
|
|
|
})
|
|
@@ -137,7 +142,10 @@ app.post('/submit', function (req, res) {
|
|
|
|
|
|
|
|
|
})
|
|
|
-
|
|
|
+ // res.header("Access-Control-Allow-Origin", "*");
|
|
|
+ // console.log(fs.readFileSync("main.js"))
|
|
|
+ // console.log(req.body.albumCover);
|
|
|
+ // res.end("")
|
|
|
|
|
|
})
|
|
|
|
|
@@ -181,12 +189,11 @@ app.options('/search_api', function (req, res) {
|
|
|
})
|
|
|
app.get("/getSingle", function (req, res) {
|
|
|
if (req.query.id) {
|
|
|
- db.execute(`SELECT song_name, album_name, artist, kind
|
|
|
+ db.execute(`SELECT song_name, album_name, artist, kind, albumcover
|
|
|
FROM instrunet_entry
|
|
|
WHERE uuid = "${req.query.id}"`, function (err, rows) {
|
|
|
if (err) {
|
|
|
console.log(err);
|
|
|
-
|
|
|
}
|
|
|
res.contentType("application/json");
|
|
|
res.header("Access-Control-Allow-Origin", "*");
|
|
@@ -253,16 +260,16 @@ app_serve.get('/:uuid', function (req, res, next) {
|
|
|
|
|
|
// TODO Always use HTTPS before publishing.
|
|
|
|
|
|
-https.createServer({
|
|
|
- key: fs.readFileSync('andyxie.cn.key'), cert: fs.readFileSync('andyxie.cn.pem')
|
|
|
-}, app).listen(8080)
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-https.createServer({
|
|
|
- key: fs.readFileSync('andyxie.cn.key'), cert: fs.readFileSync('andyxie.cn.pem')
|
|
|
-
|
|
|
-}, app_serve).listen(8079)
|
|
|
-
|
|
|
-// app.listen(8080)
|
|
|
-// app_serve.listen(8079)
|
|
|
+// https.createServer({
|
|
|
+// key: fs.readFileSync('andyxie.cn.key'), cert: fs.readFileSync('andyxie.cn.pem')
|
|
|
+// }, app).listen(8080)
|
|
|
+//
|
|
|
+//
|
|
|
+//
|
|
|
+// https.createServer({
|
|
|
+// key: fs.readFileSync('andyxie.cn.key'), cert: fs.readFileSync('andyxie.cn.pem')
|
|
|
+//
|
|
|
+// }, app_serve).listen(8079)
|
|
|
+
|
|
|
+app.listen(8080)
|
|
|
+app_serve.listen(8079)
|