initial
This commit is contained in:
24
pages/api/contact.js
Normal file
24
pages/api/contact.js
Normal file
@@ -0,0 +1,24 @@
|
||||
export default function (req, res) {
|
||||
let nodemailer = require("nodemailer");
|
||||
const transporter = nodemailer.createTransport({
|
||||
port: 465,
|
||||
host: "",
|
||||
auth: {
|
||||
user: "",
|
||||
pass: "",
|
||||
},
|
||||
secure: true,
|
||||
});
|
||||
const mailData = {
|
||||
from: "",
|
||||
to: "",
|
||||
subject: `Message From ${req.body.name}`,
|
||||
text: req.body.message,
|
||||
html: <div>{req.body.message}</div>,
|
||||
};
|
||||
transporter.sendMail(mailData, function (err, info) {
|
||||
if (err) console.log(err);
|
||||
else console.log(info);
|
||||
});
|
||||
console.log(req.body);
|
||||
}
|
||||
22
pages/api/hello.js
Normal file
22
pages/api/hello.js
Normal file
@@ -0,0 +1,22 @@
|
||||
// Next.js API route support: https://nextjs.org/docs/api-routes/introduction
|
||||
|
||||
let len = 123; //
|
||||
let przekroj = 35; //
|
||||
let threephase = 2; //
|
||||
|
||||
let resistance = len / (przekroj * 35);
|
||||
let moc = threephase * 7;
|
||||
let wsp = 0.59; ///
|
||||
let kom = 0;
|
||||
let wspplus = moc * wsp + kom;
|
||||
let Uodc = (wspplus / (3 * 230)) * 1000;
|
||||
let spadek = Uodc * resistance;
|
||||
|
||||
console.log(spadek);
|
||||
|
||||
let a = [
|
||||
1, 0.59, 0.45, 0.38, 0.34, 0.31, 0.29, 0.27, 0.26, 0.25, 0.232, 0.217, 0.208,
|
||||
0.193, 0.183, 0.175, 0.168, 0.161, 0.155, 0.15, 0.145, 0.141, 0.137, 0.133,
|
||||
0.13, 0.127, 0.124, 0.121, 0.119, 0.117, 0.115, 0.113, 0.111, 0.109, 0.107,
|
||||
0.105, 0.104, 0.103, 0.101, 0.1, 0.1,
|
||||
];
|
||||
38
pages/api/spawn.js
Normal file
38
pages/api/spawn.js
Normal file
@@ -0,0 +1,38 @@
|
||||
import { spawn } from "child_process";
|
||||
export default function (req, res) {
|
||||
console.log("spawnin");
|
||||
//console.log(req.body);
|
||||
//file
|
||||
let textData = req.body.profil;
|
||||
let replacedData = textData.replace("<22>", "o").replace("<22>", "e");
|
||||
console.log(replacedData);
|
||||
|
||||
var fs = require("fs");
|
||||
fs.writeFile("P.txt", replacedData, function (err) {
|
||||
if (err) {
|
||||
return console.error(err);
|
||||
}
|
||||
});
|
||||
|
||||
//py
|
||||
|
||||
const python = spawn("python3", ["a.py"]);
|
||||
|
||||
let dataToSend;
|
||||
python.stdout.on("data", function (data) {
|
||||
console.log("Pipe data from python script ...");
|
||||
dataToSend = data.toString();
|
||||
//console.log(dataToSend)
|
||||
});
|
||||
python.stderr.on('data', (data) => {
|
||||
console.error(`stderr: ${data}`);
|
||||
});
|
||||
// in close event we are sure that stream from child process is closed
|
||||
python.on("close", (code) => {
|
||||
console.log(`child process close all stdio with code ${code}`);
|
||||
// send data to browser
|
||||
console.log(dataToSend);
|
||||
console.log("done");
|
||||
res.send("dataToSend");
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user