私は NodeJS 環境が初めてです
- サーバーに保存されているイメージをAndroidクライアントで使用しようとしています
- 通常、サーバーでデータ(非、画像)のJSONを生成します
JSON.stringify
以下のプログラムを使用して、MySQL テーブルからデータを取得し、JSON に変換することに成功しました。
var http = require('http');
var mysql = require('mysql');
var connection = mysql.createConnection({
host: 'localhost',
user: 'root',
password: 'root',
database: 'test_programs_database'
});
http.createServer(function (request, response)
{
console.log('Creating the http server');
connection.query('SELECT id, content FROM test WHERE id IN (1, 2)', function(err, rows, fields)
{
console.log('Connection result error '+err);
console.log('no of records is '+rows.length);
response.writeHead(200, { 'Content-Type': 'application/json'});
response.end(JSON.stringify(rows));
//response.end();
});
}).listen(8084);
NodeJSを使用してサーバーのデータベースに保存されている画像を処理するには? これを理解するのに役立つ学習資料への適切なリンクは役に立ちます