Created
May 18, 2019 10:32
-
-
Save goldalworming/05b4411e605474f801413680c73de87e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | |
} | |
}); |
Author
goldalworming
commented
May 18, 2019
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment