File size: 1,527 Bytes
e77764b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
const express = require('express');
const app = express();
const path = require('path');
const bodyParser = require("body-parser");
const PORT = process.env.PORT || 7860;

// Events limit එක වැඩි කිරීම
require('events').EventEmitter.defaultMaxListeners = 500;

// Middleware (මේවා routes වලට කලින් තියෙන්න ඕනේ)
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: true }));

// CSS, JS, Images වගේ static files load වෙන්න මේක ඕනේ
app.use(express.static(path.join(__dirname, '.')));

// Routes
let code = require('./pair');
app.use('/code', code);

// Pairing page එක පෙන්වන්න
app.get('/pair', (req, res) => {
    res.sendFile(path.join(__dirname, 'pair.html'));
});

// Main UI එක පෙන්වන්න (Link එකට ගිය ගමන් පෙනෙන තැන)
app.get('/main', (req, res) => {
    res.sendFile(path.join(__dirname, 'main.html'));
});

// Root URL එකට (/) ගිය ගමන් පෙන්වන දේ - මෙතනට main.html එකම දෙමු
app.get('/', (req, res) => {
    res.sendFile(path.join(__dirname, 'main.html'));
});

// Server එක Start කිරීම
app.listen(PORT, () => {
    console.log(`

---------------------------------------

Server is live on port: ${PORT}

Hugging Face URL: http://localhost:${PORT}

---------------------------------------

    `);
});

module.exports = app;