[英]Node.js: Send XML response from different files
Having a XML response like: 具有以下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" ?>\n<Response>\n<Say>Thanks for your text, we\'ll be in touch.</Say>\n</Response>'
res.send twiml, {'Content-Type':'text/xml'}, 200
Can I have different . 我可以有所不同吗?
XML
files and res.send
them depending on conditions? XML
文件和res.send
他们根据条件?
Sure; 当然; you're using Express, right?
您正在使用Express,对吗? Use
res.sendfile
: 使用
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'
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.