update,
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
// Next.js API route support: https://nextjs.org/docs/api-routes/introduction
|
||||
|
||||
export default function handler(req, res) {
|
||||
res.status(200).json({ name: "John Doe" });
|
||||
}
|
8
vinniesniper-54816/task1/project/frontend/pages/api/test.sh
Executable file
8
vinniesniper-54816/task1/project/frontend/pages/api/test.sh
Executable file
@@ -0,0 +1,8 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# curl -X POST -H "Content-Type: application/json" -d '{"name":"John Doe","age":30}' http://localhost:5000/api/data
|
||||
|
||||
# curl http://localhost:5000/api/data
|
||||
# curl -F "file=@test.txt" http://localhost:3000/api/hello
|
||||
curl -X POST -F "file=@test.txt" http://localhost:3000/api/testFileupload
|
||||
|
@@ -0,0 +1 @@
|
||||
helloworld
|
@@ -0,0 +1,21 @@
|
||||
//
|
||||
import formidable from "formidable";
|
||||
|
||||
export const config = {
|
||||
api: {
|
||||
bodyParser: false,
|
||||
},
|
||||
};
|
||||
|
||||
export default function handler(req, res) {
|
||||
try {
|
||||
const form = new formidable.IncomingForm();
|
||||
form.parse(req, async (err, fields, files) => {
|
||||
console.log(files.zip.filepath, 222);
|
||||
const lottieJSON = await zip2json(files.zip.filepath);
|
||||
return res.status(200).json({ json: lottieJSON?.[0] });
|
||||
});
|
||||
} catch (error) {
|
||||
res.status(400).json({ error: JSON.stringify(error, Object.getOwnPropertyNames(error)) });
|
||||
}
|
||||
}
|
@@ -0,0 +1,19 @@
|
||||
//
|
||||
import formidable from "formidable";
|
||||
import axios from "axios";
|
||||
import fs from "fs";
|
||||
|
||||
// export const config = {
|
||||
// api: { bodyParser: false },
|
||||
// };
|
||||
|
||||
export default async function handler(req, res) {
|
||||
try {
|
||||
// console.log(req.body);
|
||||
const response = await axios.post("http://localhost:5000/uploader", req.body);
|
||||
console.log(response);
|
||||
res.status(200).json(response.data);
|
||||
} catch (error) {
|
||||
res.status(500).json({ error: error.message });
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user