Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
var express = require('express');
var app = express();
var Server = require('http').Server;
var server = new Server(app);
var cors = require('cors')
var port = 3131
app.options('*', cors())
app.use(express.urlencoded({ extended: true }));
app.use(express.json());
server.listen(port);
app.get('/*', function (req, res, next) {
res.setHeader('Access-Control-Allow-Origin', '*')
next();
});
app.post('/*', function (req, res, next) {
res.setHeader('Access-Control-Allow-Origin', '*')
next();
});
app.use('/', express.static(__dirname + '/views'));
app.get('/', function (req, res) {
res.sendFile(__dirname + '/views/index.html');
});
app.get('/tes/:val', async (req, res, next) => {
try{
if(req.params.val&&req.params.val!=''){
globalval["val"] = req.params.val
}
let url = req.query.url;
let user = {"name":'tes'}
res.json(user);
}catch(err){
next(err)
}
});
@goldalworming

This comment has been minimized.

Copy link
Owner Author

commented May 18, 2019

async sendaxios(){
  console.log(locserv)
  let resp = await axios.post(locserv+"/setting/deFolder", {defolder:'xyz'})
  console.log(resp)
},
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.