blockly/server/src/index.ts

24 lines
582 B
TypeScript

// Importing express module
import express from "express";
import bodyParser from 'body-parser';
import cors from 'cors';
import * as fs from 'fs';
const app = express();
app.use(cors())
app.use(bodyParser.text());
// Handling GET / request
app.post("/set/:file", (req, res) => {
fs.writeFileSync(`/home/anton/minecraft_scriptcraft/scriptcraft/plugins/blocklycraft/aggtaa/${req.params.file}.js`, req.body, 'utf-8');
// res.send("This is the express server " + JSON.stringify(req.body));
res.send('');
});
app.listen(8081, () => {
console.log("Server is Running");
});