-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.js
58 lines (50 loc) · 1.79 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
var express = require('express');
var app = express();
var cors = require('cors');
app.use( cors() )
// app.options("*", cors());
// app.use(express.static('client/build'));
// include v3 folder
// app.use(express.static('v3/textures'));
// app.use(express.static('vr'));
const path = require('path');
app.use(function(req, res, next) {
res.header("Access-Control-Allow-Origin", "*");
res.header("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept");
next()
})
// main site
app.get('/', function(req, res, next){
res.header('Content-Type', 'text/html')
res.sendFile(path.join(__dirname, 'index.html'))
})
app.get('/places.css', function(req, res, next){
res.header('Content-Type', 'text/css')
res.sendFile(path.join(__dirname, 'places.css'))
})
app.get('/lib/three.module.js', function(req, res){
res.header('Content-Type', 'text/javascript')
res.sendFile(path.join(__dirname, 'lib', 'three.module.js'))
})
app.get('/lib/:filename', function(req, res){
res.header('Content-Type', 'text/javascript')
console.log("libbo", req.params.filename)
res.sendFile(path.join(__dirname, 'lib', req.params.filename))
})
app.get('/textures/:filename', function(req, res){
res.header('Content-Type', 'image/jpg')
console.log("texture", req.params.filename)
res.sendFile(path.join(__dirname, 'textures', req.params.filename))
})
app.get('/sounds/:filename', function(req, res){
res.header('Content-Type', 'audio/mp3')
console.log("sound", req.params.filename)
res.sendFile(path.join(__dirname, 'sounds', req.params.filename))
})
app.get('/models/:filename', function(req, res){
res.header('Content-Type', 'model/gltf+json')
console.log("model", req.params.filename)
res.sendFile(path.join(__dirname, 'models', req.params.filename))
})
// main site
app.listen(4000);