gaveshvimanshan commited on
Commit
d6c3e5d
·
verified ·
1 Parent(s): 65fb1fd

Create index.js

Browse files
Files changed (1) hide show
  1. index.js +46 -0
index.js ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ const express = require('express');
2
+ const app = express();
3
+ const path = require('path');
4
+ const bodyParser = require("body-parser");
5
+ const PORT = process.env.PORT || 7860;
6
+
7
+ // Events limit එක වැඩි කිරීම
8
+ require('events').EventEmitter.defaultMaxListeners = 500;
9
+
10
+ // Middleware (මේවා routes වලට කලින් තියෙන්න ඕනේ)
11
+ app.use(bodyParser.json());
12
+ app.use(bodyParser.urlencoded({ extended: true }));
13
+
14
+ // CSS, JS, Images වගේ static files load වෙන්න මේක ඕනේ
15
+ app.use(express.static(path.join(__dirname, '.')));
16
+
17
+ // Routes
18
+ let code = require('./pair');
19
+ app.use('/code', code);
20
+
21
+ // Pairing page එක පෙන්වන්න
22
+ app.get('/pair', (req, res) => {
23
+ res.sendFile(path.join(__dirname, 'pair.html'));
24
+ });
25
+
26
+ // Main UI එක පෙන්වන්න (Link එකට ගිය ගමන් පෙනෙන තැන)
27
+ app.get('/main', (req, res) => {
28
+ res.sendFile(path.join(__dirname, 'main.html'));
29
+ });
30
+
31
+ // Root URL එකට (/) ගිය ගමන් පෙන්වන දේ - මෙතනට main.html එකම දෙමු
32
+ app.get('/', (req, res) => {
33
+ res.sendFile(path.join(__dirname, 'main.html'));
34
+ });
35
+
36
+ // Server එක Start කිරීම
37
+ app.listen(PORT, () => {
38
+ console.log(`
39
+ ---------------------------------------
40
+ Server is live on port: ${PORT}
41
+ Hugging Face URL: http://localhost:${PORT}
42
+ ---------------------------------------
43
+ `);
44
+ });
45
+
46
+ module.exports = app;