minor changes
This commit is contained in:
parent
909b29dfb5
commit
af2e220116
30 changed files with 598 additions and 350 deletions
|
|
@ -7,24 +7,24 @@ const DB_ASSIGNMENT_SERVICE_URL = process.env.DB_ASSIGNMENT_SERVICE_URL;
|
|||
const DEPLOY_API_URL = process.env.DEPLOY_API_URL || "http://localhost:3600";
|
||||
|
||||
studentRouter.post("/save", async (req, res) => {
|
||||
//get the app name and code and save the latest jupyter file in s3 bucket
|
||||
const { appName, code } = req.body;
|
||||
//get the app name and code and save the latest jupyter file in s3 bucket
|
||||
const { appName, code } = req.body;
|
||||
|
||||
console.log("Received save request for app:", appName);
|
||||
console.log("Received save request for app:", appName);
|
||||
|
||||
const notebook = {
|
||||
cells: [
|
||||
const notebook = {
|
||||
cells: [
|
||||
{
|
||||
cell_type: "code",
|
||||
execution_count: null,
|
||||
metadata: {
|
||||
language: "python"
|
||||
language: "python"
|
||||
},
|
||||
outputs: [],
|
||||
source: code.split('\n').map(line => line + '\n')
|
||||
}
|
||||
],
|
||||
metadata: {
|
||||
],
|
||||
metadata: {
|
||||
kernelspec: {
|
||||
display_name: "Python 3",
|
||||
language: "python",
|
||||
|
|
@ -34,36 +34,36 @@ studentRouter.post("/save", async (req, res) => {
|
|||
name: "python",
|
||||
version: "3.x"
|
||||
}
|
||||
},
|
||||
nbformat: 4,
|
||||
nbformat_minor: 5
|
||||
};
|
||||
},
|
||||
nbformat: 4,
|
||||
nbformat_minor: 5
|
||||
};
|
||||
|
||||
// Convert the notebook object to a JSON string and then to base64
|
||||
const jsonString = JSON.stringify(notebook, null, 2);
|
||||
const base64 = Buffer.from(jsonString, 'utf-8').toString('base64');
|
||||
// Convert the notebook object to a JSON string and then to base64
|
||||
const jsonString = JSON.stringify(notebook, null, 2);
|
||||
const base64 = Buffer.from(jsonString, 'utf-8').toString('base64');
|
||||
|
||||
const notebookName = `${Date.now()}-notebook.ipynb`;
|
||||
console.log("DEPLOY_API_URL:", DEPLOY_API_URL);
|
||||
console.log("Uploading notebook:", notebookName, "to app:", appName);
|
||||
const notebookName = `${Date.now()}-notebook.ipynb`;
|
||||
console.log("DEPLOY_API_URL:", DEPLOY_API_URL);
|
||||
console.log("Uploading notebook:", notebookName, "to app:", appName);
|
||||
|
||||
await fetch(`${DEPLOY_API_URL}/${appName}/upload`, {
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify({ notebookName: notebookName, fileContentBase64: base64 })
|
||||
await fetch(`${DEPLOY_API_URL}/${appName}/upload`, {
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify({ notebookName: notebookName, fileContentBase64: base64 })
|
||||
})
|
||||
.then((response) => {
|
||||
if (!response.ok) throw new Error("Failed to save notebook");
|
||||
return response.json();
|
||||
})
|
||||
.then((response) => {
|
||||
if (!response.ok) throw new Error("Failed to save notebook");
|
||||
return response.json();
|
||||
})
|
||||
.then((data) => {
|
||||
console.log("Notebook saved successfully:", data);
|
||||
res.status(200).json(data);
|
||||
})
|
||||
.catch((error) => {
|
||||
console.error("Error saving notebook:", error.message);
|
||||
res.status(500).json({ error: error.message });
|
||||
});
|
||||
.then((data) => {
|
||||
console.log("Notebook saved successfully:", data);
|
||||
res.status(200).json(data);
|
||||
})
|
||||
.catch((error) => {
|
||||
console.error("Error saving notebook:", error.message);
|
||||
res.status(500).json({ error: error.message });
|
||||
});
|
||||
});
|
||||
|
||||
studentRouter.get("/assignment/:qrnum", (req, res) => {
|
||||
|
|
@ -105,7 +105,7 @@ studentRouter.post("/verify", async (req, res) => {
|
|||
|
||||
const isPasswordValid = await bcrypt.compare(
|
||||
password,
|
||||
response.data.passwordhash
|
||||
response.data.passwordhash
|
||||
);
|
||||
|
||||
console.log("Password validation result:", isPasswordValid);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue