- server_static.js
- sget.js
- index.html
Last active
June 19, 2017 00:11
-
-
Save rpragana/8535e89450d7db76132a8e1eb90d7e57 to your computer and use it in GitHub Desktop.
NodeJS REPL
This file contains 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
<!doctype html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
</head> | |
<body> | |
<h1>Servidor web</h1> | |
<p>Este servidor Express serve arquivos estáticos.</p> | |
<a href="/teste">Rota "/teste"</a> | |
</body> | |
</html> |
This file contains 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
#!/usr/bin/env nodemon | |
var fs = require('fs'); | |
var path = require('path'); | |
var express = require('express'); | |
var app = express() | |
app.use(express.static(__dirname + '/')); | |
app.listen(8000); | |
console.log('Aponte seu navegador para https://localhost:8000/'); | |
// -- incluindo o REPL na nossa aplicação | |
var s = "Uma mensagem para verificação." | |
var t = "Outra mensagem" | |
var repl = require('repl'); | |
var rinst = repl.start('> '); | |
rinst.context.s = s | |
rinst.context.app = app |
This file contains 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
var appret = app.get('/teste', function(req, res) { | |
res.send('<h1>Express server</h1>'+ | |
'<p>Retornando pela rota "/teste"</p>'); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment