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
function uid() { | |
const head = Date.now().toString(36) | |
const tail = Math.random().toString(36).substring(2) | |
return head + tail | |
} | |
uid() |
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
// Replace the line 252 to 316 by this | |
if (messageText) { | |
const greeting = new RegExp(/^(kaiz|kez|slt|salut|bjr|bonjour|hi|hello|hey|hola)/i) | |
if (messageText.match(greeting)) { | |
sayHello(senderID) | |
} else if (messageText.match('image')) { | |
sendImageMessage(senderID) | |
} else if (messageText.match('gif')) { |
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
// Create a folder mymodule and put this in file named mymodule.js | |
const kaizKaiz = () => { | |
console.log('Kaiza kaiza daholo e !') | |
} | |
const surSur = function() { | |
console.log('Sur sur e !') | |
} | |
exports.kaizKaiz = kaizKaiz |
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
const EventEmitter = require('events').EventEmitter | |
const zavatra = new EventEmitter() | |
zavatra.on('velona', (message) => { | |
console.log(message) | |
}) | |
zavatra.emit('velona', 'Io fa velona !') |
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
const http = require('http') | |
const server = http.createServer((req, res) => { | |
res.writeHead(200) | |
res.end('Hi everybody !') | |
}) | |
/* | |
const server = http.createServer() | |
server.on('request', (req, res) => { |
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
const http = require('http') | |
const url = require('url') | |
const querystring = require('querystring') | |
const server = http.createServer((req, res) => { | |
const settings = querystring.parse(url.parse(req.url).query) | |
res.writeHead(200, {"Content-Type": "text/plain"}) | |
if ('firstname' in settings && 'name' in settings) { | |
res.write('Your name: ' + settings['firstname'] + ' ' + settings['name']) | |
} |
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
const http = require('http') | |
const url = require('url') | |
const server = http.createServer((req, res) => { | |
const page = url.parse(req.url).pathname | |
console.log(page) | |
res.writeHead(200, {"Content-Type": "text/plain"}) | |
if (page == '/') { | |
res.write('Home') | |
} |
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
const http = require('http') | |
const url = require('url') | |
const server = http.createServer((req, res) => { | |
const page = url.parse(req.url).pathname | |
console.log(page) | |
res.writeHead(200, {"Content-Type": "text/plain"}) | |
res.write('Hello everybody !') | |
res.end() | |
}) |
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
const http = require('http') | |
const server = http.createServer((req, res) => { | |
res.writeHead(200, {"Content-Type": "text/html"}) | |
res.end('<h1>Hi everybody !</h1>') | |
}) | |
server.listen(8080) |
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
const http = require('http') | |
const server = http.createServer((req, res) => { | |
res.writeHead(200) | |
res.end('Hello everybody !') | |
}) | |
server.listen(8080) |
NewerOlder