-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
25 lines (20 loc) · 709 Bytes
/
server.js
File metadata and controls
25 lines (20 loc) · 709 Bytes
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
const express = require('express')
const path = require('path')
const app = express()
const PORT = process.env.PORT || 3000
app.use(express.static(path.join(__dirname, 'public')))
app.get('/', (req, res) => {
res.sendFile(path.join(__dirname, 'index.html'))
})
app.use('/downloads', express.static('/downloads', {
setHeaders: (res, filePath) => {
// Force download for installer files
const ext = path.extname(filePath).toLowerCase()
if (['.dmg', '.exe', '.appimage'].includes(ext)) {
res.setHeader('Content-Disposition', `attachment; filename="${path.basename(filePath)}"`)
}
}
}))
app.listen(PORT, () => {
console.log(`terminalOS landing page running on port ${PORT}`)
})