var express = require('express'); var app = express(); app.use(express.static('public')); app.listen(80, function () { console.log('Example app listening on port 80!'); });
在index.html中获取如下:
1 2 3
$.getJSON('conf/demo.json', function (data) { console.log(data); })
2.服务端 index.js内容如下:
1 2 3 4 5 6 7 8 9
var express = require('express'); var app = express(); var CONFPATH = "./public/conf/demo.json"; var fs = require('fs'); var result = JSON.parse(fs.readFileSync(CONFPATH)); console.log(result); app.listen(80, function () { console.log('Example app listening on port 80!'); });
var email = require("emailjs"); var server = email.server.connect({ user: "aibibang@sohu.com", password:"*********", host: "smtp.sohu.com", ssl: false });
// send the message and get a callback with an error or details of the message that was sent server.send({ text: "i hope this works", from: "aibibang@sohu.com", to: "aibibang@sohu.com", subject: "testing emailjs" }, function(err, message) { console.log(err || message); });
{ Error: no form of authorization supported at module.exports (/data/truman/node/node_modules/emailjs/smtp/error.js:2:13) at initiate (/data/truman/node/node_modules/emailjs/smtp/smtp.js:543:44) at caller (/data/truman/node/node_modules/emailjs/smtp/smtp.js:48:14) at attempt (/data/truman/node/node_modules/emailjs/smtp/smtp.js:415:14) at caller (/data/truman/node/node_modules/emailjs/smtp/smtp.js:48:14) at response (/data/truman/node/node_modules/emailjs/smtp/smtp.js:345:13) at caller (/data/truman/node/node_modules/emailjs/smtp/smtp.js:48:14) at response (/data/truman/node/node_modules/emailjs/smtp/smtp.js:201:11) at caller (/data/truman/node/node_modules/emailjs/smtp/smtp.js:48:14) at Socket.response (/data/truman/node/node_modules/emailjs/smtp/smtp.js:181:11) code: 7,