首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何从couchdb请求htm附件,然后在浏览器上作为html?

如何从couchdb请求htm附件,然后在浏览器上作为html?
EN

Stack Overflow用户
提问于 2012-10-08 06:08:24
回答 1查看 112关注 0票数 1

结合使用express和coffeescript。我希望发生的是,请求将从couchdb获得test.htm,然后呈现该htm文件(这是正确的术语吗?)在浏览器上。

我的app.coffee上有这个

代码语言:javascript
复制
app.get "/testreq", (req, res) ->
  gets = require("request")
  myurl = gets 'http://jims.iriscouch.com:5984/album/attachment_id/test.htm'
  res.send myurl

在我的浏览器上,当我转到"/testreq“时,我得到的是这些...

代码语言:javascript
复制
 `{   "readable": true,   "writable": true,   "__isRequestRequest": true,   "_redirectsFollowed": 0,   "maxRedirects": 10,   "followRedirect": true,   "followAllRedirects": false,   "setHost": true,   "port": "5984",   "host": "jims.iriscouch.com",   "path": "/album/1d22186ee496b5ada564a9888d003203/test.htm",   "uri": {     "protocol": "http:",     "slashes": true,     "host": "jims.iriscouch.com:5984",     "port": "5984",     "hostname": "jims.iriscouch.com",     "href": "http://jims.iriscouch.com:5984/album/1d22186ee496b5ada564a9888d003203/test.htm",     "pathname": "/album/1d22186ee496b5ada564a9888d003203/test.htm",     "path": "/album/1d22186ee496b5ada564a9888d003203/test.htm"   },   ....` 

将res.send myurl改为res.render myurl会给我一个错误(500错误:无法查找视图"object Object")。

我应该怎么做才能让test.htm (来自couchdb)在浏览器上呈现为html?

感谢您的帮助!

EN

回答 1

Stack Overflow用户

发布于 2012-10-08 06:23:15

这样啊,原来是这么回事!

代码语言:javascript
复制
  myurl.pipe res

感谢您的光临!

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/12773284

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档