| const express = require("express"); |
|
|
| const app = express(); |
|
|
| const PORT = process.env.PORT || 5900; |
|
|
| const htmlContent = ` |
| <!DOCTYPE html> |
| <html> |
| <head> |
| <title>RAM Size API</title> |
| </head> |
| <body> |
| <h1>RAM Size API</h1> |
| <p><a href="/get-ram">/get-ram</a></p> |
| </body> |
| </html> |
| `; |
|
|
| app.get("/", (req, res) => { |
| res.send(htmlContent); |
| }); |
|
|
| app.get("/get-ram", (req, res) => { |
|
|
| const ramSizes = [ |
| 512, |
| 1024, |
| 2048, |
| 4096 |
| ]; |
|
|
| const ramMB = |
| ramSizes[ |
| Math.floor(Math.random() * ramSizes.length) |
| ]; |
|
|
| res.json({ |
| ram_mb: ramMB |
| }); |
| }); |
|
|
| app.listen(PORT, "0.0.0.0", () => { |
| console.log( |
| `Server running on http://127.0.0.1:${PORT}` |
| ); |
| }); |