Spaces:
Paused
Paused
Update index.js
Browse files
index.js
CHANGED
|
@@ -3,6 +3,7 @@ const app = express();
|
|
| 3 |
|
| 4 |
const validApiKeys = ['your_valid_api_key1', 'your_valid_api_key2'];
|
| 5 |
|
|
|
|
| 6 |
app.get('/checkState', (req, res) => {
|
| 7 |
const { apikey } = req.query;
|
| 8 |
|
|
@@ -10,14 +11,19 @@ app.get('/checkState', (req, res) => {
|
|
| 10 |
const serverState = {
|
| 11 |
message: 'Server is running successfully',
|
| 12 |
server: 'running',
|
| 13 |
-
|
| 14 |
res.status(200).json(serverState);
|
| 15 |
} else {
|
| 16 |
res.status(401).json({ message: 'Invalid API key' });
|
| 17 |
}
|
| 18 |
});
|
| 19 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 20 |
const PORT = 7860;
|
| 21 |
app.listen(PORT, () => {
|
| 22 |
-
console.log(`Server is running on port ${
|
| 23 |
});
|
|
|
|
| 3 |
|
| 4 |
const validApiKeys = ['your_valid_api_key1', 'your_valid_api_key2'];
|
| 5 |
|
| 6 |
+
// Route to check server state based on API key
|
| 7 |
app.get('/checkState', (req, res) => {
|
| 8 |
const { apikey } = req.query;
|
| 9 |
|
|
|
|
| 11 |
const serverState = {
|
| 12 |
message: 'Server is running successfully',
|
| 13 |
server: 'running',
|
| 14 |
+
};
|
| 15 |
res.status(200).json(serverState);
|
| 16 |
} else {
|
| 17 |
res.status(401).json({ message: 'Invalid API key' });
|
| 18 |
}
|
| 19 |
});
|
| 20 |
|
| 21 |
+
// Root route to display "Hello World"
|
| 22 |
+
app.get('/', (req, res) => {
|
| 23 |
+
res.send('Hello World');
|
| 24 |
+
});
|
| 25 |
+
|
| 26 |
const PORT = 7860;
|
| 27 |
app.listen(PORT, () => {
|
| 28 |
+
console.log(`Server is running on port ${PORT}`);
|
| 29 |
});
|