Javascript Node.js:从不同文件发送XML响应
具有如下XML响应:Javascript Node.js:从不同文件发送XML响应,javascript,xml,node.js,coffeescript,Javascript,Xml,Node.js,Coffeescript,具有如下XML响应: app.post '/incoming', (req,res) -> console.log "Hello, incoming call!" message = req.body.Body from = req.body.From sys.log "From: " + from + ", Message: " + message twiml = '<?xml version="1.0" encoding="UTF-8"
app.post '/incoming', (req,res) ->
console.log "Hello, incoming call!"
message = req.body.Body
from = req.body.From
sys.log "From: " + from + ", Message: " + message
twiml = '<?xml version="1.0" encoding="UTF-8" ?>\n<Response>\n<Say>Thanks for your text, we\'ll be in touch.</Say>\n</Response>'
res.send twiml, {'Content-Type':'text/xml'}, 200
app.post'/incoming',(请求、回复)->
console.log“你好,来电!”
消息=req.body.body
from=req.body.from
sys.log“From:+From+”,Message:+Message
twiml='\n\n感谢您的短信,我们将保持联系。\n
res.send twiml,{'Content-Type':'text/xml'},200
我可以拥有不同的。
XML
文件和res。根据条件发送它们吗?当然;你在用快车,对吗?使用res.sendfile
:
app.post '/incoming', (req,res) ->
console.log "Hello, incoming call!"
message = req.body.Body
from = req.body.From
sys.log "From: " + from + ", Message: " + message
if condition
res.sendfile 'foo.xml'
else
res.sendfile 'bar.xml'
当然;你在用快车,对吗?使用res.sendfile:
app.post '/incoming', (req,res) ->
console.log "Hello, incoming call!"
message = req.body.Body
from = req.body.From
sys.log "From: " + from + ", Message: " + message
if condition
res.sendfile 'foo.xml'
else
res.sendfile 'bar.xml'