Skip to content

Instantly share code, notes, and snippets.

@goldalworming
Created May 18, 2019 10:32
Show Gist options
  • Save goldalworming/05b4411e605474f801413680c73de87e to your computer and use it in GitHub Desktop.
Save goldalworming/05b4411e605474f801413680c73de87e to your computer and use it in GitHub Desktop.
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
Copy link
Author

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