Add uziom generation script and update wet input documents
- Created a new Python script `uziom.py` for generating DXF drawings of grounding systems based on user input parameters. - Added detailed documentation in `wet_input_15.docx` and `wet_input_3.docx` for the design of grounding systems, including calculations for resistance and resistivity measurements. - Included placeholders for dynamic data insertion in the documents to facilitate project-specific customization.
This commit is contained in:
56
pages/api/external.js
Normal file
56
pages/api/external.js
Normal file
@@ -0,0 +1,56 @@
|
||||
import Cors from "cors";
|
||||
|
||||
import fs from "fs";
|
||||
|
||||
// Initializing the cors middleware
|
||||
// You can read more about the available options here: https://github.com/expressjs/cors#configuration-options
|
||||
const cors = Cors({
|
||||
methods: ["POST"],
|
||||
});
|
||||
|
||||
// Helper method to wait for a middleware to execute before continuing
|
||||
// And to throw an error when an error happens in a middleware
|
||||
function runMiddleware(req, res, fn) {
|
||||
return new Promise((resolve, reject) => {
|
||||
fn(req, res, (result) => {
|
||||
if (result instanceof Error) {
|
||||
return reject(result);
|
||||
}
|
||||
|
||||
return resolve(result);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
export default async function handler(req, res) {
|
||||
// Run the middleware
|
||||
await runMiddleware(req, res, cors);
|
||||
|
||||
const id = Math.floor(Math.random() * 90000) + 10000;
|
||||
const textData = req.body;
|
||||
|
||||
let data = textData.split(",");
|
||||
|
||||
let text = "Próbkowanie: 1\nSegment 0: w dół\nX: Y, Z\n";
|
||||
let i = 1;
|
||||
for (let snippet of data) {
|
||||
if (i % 3 != 0) {
|
||||
text += snippet + ",";
|
||||
} else {
|
||||
text += snippet + "\n";
|
||||
}
|
||||
i += 1;
|
||||
}
|
||||
|
||||
// console.log(text);
|
||||
|
||||
fs.writeFile(`externals/${id}.txt`, text, (err) => {
|
||||
if (err) {
|
||||
res.status(418);
|
||||
throw err;
|
||||
}
|
||||
});
|
||||
|
||||
// console.log(textData);
|
||||
res.status(200).send({ url: `https://test.wastpol.pl/?external=tru&id=${id}` });
|
||||
}
|
||||
Reference in New Issue
Block a user