Jam*_*xon 1 azure node.js azure-functions
我有一个节点azure函数与function.json像这样:
{
"disabled": false,
"bindings": [
{
"name": "req",
"type": "httpTrigger",
"direction": "in",
"methods": [ "get" ]
},
{
"name": "res",
"type": "http",
"direction": "out"
}
]
}
Run Code Online (Sandbox Code Playgroud)
但是,当我像这样写index.js时:
module.exports = function (context, sentimentTable) {
context.res = {
body: "<!DOCTYPE html> <html> <head> </head> <body> Hello World </body> </html>",
contentType: "text/html"
};
context.done();
};
Run Code Online (Sandbox Code Playgroud)
我得到这个:
Azure函数可以返回html吗?
必须是"Content-Type",您可以通过这种方式指定标题
context.res = {
body: '...',
headers: {
'Content-Type': 'text/html; charset=utf-8'
}
}
Run Code Online (Sandbox Code Playgroud)
在AzureServerless.com上查看此博客文章 - http://azureserverless.com/2016/11/12/a-html-nanoserver/
| 归档时间: |
|
| 查看次数: |
777 次 |
| 最近记录: |