Add index.js
This commit is contained in:
@@ -0,0 +1,39 @@
|
|||||||
|
const http = require('http');
|
||||||
|
|
||||||
|
const PORT = 3000;
|
||||||
|
|
||||||
|
// Create a server that sends a simple HTML page
|
||||||
|
const server = http.createServer((req, res) => {
|
||||||
|
res.statusCode = 200;
|
||||||
|
res.setHeader('Content-Type', 'text/html');
|
||||||
|
|
||||||
|
// Your HTML goes right here inside the backticks
|
||||||
|
res.end(`
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title>Node App</title>
|
||||||
|
<style>
|
||||||
|
body {
|
||||||
|
font-family: sans-serif;
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
height: 100vh;
|
||||||
|
margin: 0;
|
||||||
|
background-color: #f0f0f0;
|
||||||
|
}
|
||||||
|
h1 { color: #333; }
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<h1>Hey, this is working!</h1>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
`);
|
||||||
|
});
|
||||||
|
|
||||||
|
// Start the server
|
||||||
|
server.listen(PORT, () => {
|
||||||
|
console.log(`Server is running! Open your browser and go to: http://localhost:${PORT}`);
|
||||||
|
});
|
||||||
Reference in New Issue
Block a user