-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
37 lines (23 loc) · 852 Bytes
/
app.js
File metadata and controls
37 lines (23 loc) · 852 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
26
27
28
29
30
31
32
33
34
35
36
37
const express = require('express')
const path = require('path');
const donwloader = require('./downloader')
/* const {searchVideo}=require('./search') */
const searchVideoSimple = require('./searchSimple')
const dlProxy = require("./dlProxy")
const app = express()
const port = process.env.PORT || 5000;
app.use(function (_, res, next) {
res.header("Access-Control-Allow-Origin", "*");
res.header("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept");
next();
});
app.use(express.static(path.join(__dirname, 'client/build')));
app.use("/api/ytdl", donwloader);
app.use("/api/search", searchVideoSimple);
app.use("/api/dlproxy", dlProxy);
app.get('*', (_, res) => {
res.sendFile('index.html', { root: `${__dirname}/client/build` })
})
app.listen(port, () => {
console.log(`running on port ${port}`)
})