-
Notifications
You must be signed in to change notification settings - Fork 2
/
server.js
90 lines (79 loc) · 2.65 KB
/
server.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
const express =require('express');
const path = require('path');
const cors=require('cors');
const axios = require('axios');
const app= express();
const pool=require('./database/db');
//middle
app.use(express.json())
app.use(cors())
app.use(express.static(`${__dirname}/public`));
app.use(express.static(`${__dirname}/node_modules`));
app.use(express.static(`${__dirname}/data`));
app.use(express.static(`${__dirname}/potree`));
//app.use(express.static(path.join(__dirname, 'assets')));
// Redirect
app.get('/',function(req,res){
res.sendFile(__dirname + '/public/index.html');
//__dirname : It will resolve to your project folder.
});
app.get('/RGB',function(req,res){
res.sendFile(__dirname + '/public/2D/rgb.html');
});
app.get('/Multispectral',function(req,res){
res.sendFile(__dirname + '/public/2D/ms.html');
});
app.get('/NDVI',function(req,res){
res.sendFile(__dirname + '/public/2D/ndvi.html');
});
app.get('/LandCover',function(req,res){
res.sendFile(__dirname + '/public/2D/lc.html');
});
app.get('/FlightPath',function(req,res){
res.sendFile(__dirname + '/public/2D/flightpath.html');
});
app.get('/biomass',function(req,res){
res.sendFile(__dirname + '/public/2D/biomass.html');
});
app.get('/DEM',function(req,res){
res.sendFile(__dirname + '/public/2D/DEM.html');
});
app.get('/pointcloud',function(req,res){
res.sendFile(__dirname + '/public/pointcloud2023.html');
//res.sendFile(__dirname+ '/node_modules/potree/examples/shapefiles.html');
});
app.get('/ESRIMS',function(req,res){
res.sendFile(__dirname + '/public/ESRI/ms.html');
});
app.get('/ESRISense',function(req,res){
res.sendFile(__dirname + '/public/ESRI/sensebox.html');
});
//teams
app.get('/teams',function(req,res){
res.sendFile(__dirname + '/public/teams.html');
});
//about
app.get('/about',function(req,res){
res.sendFile(__dirname + '/public/about.html');
});
app.get('/geoserver-proxy', async (req, res) => {
const geoserverUrl = 'http://giv-project2.uni-muenster.de:8080/geoserver/Web_Portal/wms' + req.url;
try {
const response = await axios.get(geoserverUrl, { responseType: 'arraybuffer' });
res.set(response.headers);
res.send(response.data);
} catch (error) {
res.status(500).send(error.message);
}
});
//routes
app.use("/data",require("./routes/routes"))
const port = process.env.PORT || 9000;
app.listen(port,()=>{
console.log("Server started on port "+ port + "localhost:9000/" );
});
// Error handling middleware
app.use(function(err, req, res, next) {
console.error(err.stack);
res.status(500).send('Something broke!');
});