This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mkdir slender | |
cd slender | |
touch server.js |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const http = require('http'); | |
const PORT = 4000; | |
http.createServer(server).listen(PORT); | |
function server(req, res) { | |
res.end('Hello, dude'); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function server(req, res) { | |
const { url } = req; | |
if (url === '/') { | |
res.end('Main'); | |
} else if (url === '/about') { | |
res.end('About'); | |
} else { | |
res.end('404'); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function server(req, res) { | |
return res.end(App({ url: req.url })); | |
} | |
function App({ url }) { | |
return ` | |
<!doctype html> | |
<html class="app"> | |
<head> | |
<meta charset="utf-8" /> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.app { | |
margin: 0; | |
padding: 0; | |
background: #fff; | |
font-family: sans-serif; | |
} | |
.app__body { | |
margin: 0; | |
padding: 0; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<head> | |
<meta charset="utf-8" /> | |
<title>Slender Website</title> | |
<link rel="stylesheet" href="/styles.css" /> | |
</head> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const fs = require('fs'); | |
function server(req, res) { | |
const { url } = req; | |
if (url === '/styles.css') { | |
res.end(fs.readFileSync('./styles.css')); | |
return; | |
} | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const fs = require('fs'); | |
const styles = fs.readFileSync('./styles.css'); | |
function server(req, res) { | |
const { url } = req; | |
if (url === '/styles.css') { | |
res.end(styles); | |
return; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// server.js | |
const http = require('http'); | |
const fs = require('fs'); | |
require('./components'); | |
const PORT = 4000; | |
const styles = fs.readFileSync('./styles.css'); | |
const components = fs.readFileSync('./components.js'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.box { | |
width: 30px; | |
height: 30px; | |
background: #ccc; | |
} | |
.box_big { | |
width: 100px; | |
height: 100px; | |
} |
OlderNewer