如何以 html 形式显示服务器端 Node.js 变量中保存的文本。
换句话说,为了更加清楚,我从访问 twitter (Twitt) 的 api 中提取了输出,并且我试图在页面底部显示该文本。
网页的名称是这样的
app.get('/', function (req, res) {
res.sendfile('./Homepage.html');
});
Run Code Online (Sandbox Code Playgroud)
这是调用 Node.js 文件的地方:
var express = require('express');
var app = express();
Run Code Online (Sandbox Code Playgroud)
这是变量的位置:
T.get('search/tweets', { q: hash1 + ' since:2013-11-11', count: 5 },
function(err, reply) {
response = (reply),
console.log(response)
app.append(response)
})
Run Code Online (Sandbox Code Playgroud) 我需要在两个不同的函数中访问动态数组.在一个中进行的更改需要转移到另一个.
这些是功能:
void populate(int size, int *ptr)
{
ptr = new int[size];
for (int i = 0; i < size; i++)
{
ptr[i] = rand() % 51;
}
}
void display(int size, int *ptr)
{
for (int i=0; i < size; i++)
{
cout << ptr[i] << endl;
}
}
Run Code Online (Sandbox Code Playgroud)
它在主要被称为
int* ptr = NULL;
Run Code Online (Sandbox Code Playgroud)