mirror of
https://github.com/seejohnrun/haste-server
synced 2025-08-14 07:56:50 -07:00
Document saving almost working
This commit is contained in:
parent
7cc30e4b69
commit
7756e38595
3 changed files with 63 additions and 14 deletions
38
server.js
38
server.js
|
@ -50,9 +50,43 @@ StaticHandler.prototype.handle = function(request, response) {
|
|||
|
||||
///////////
|
||||
|
||||
var documents = {};
|
||||
|
||||
var DocumentHandler = function() {
|
||||
|
||||
};
|
||||
|
||||
DocumentHandler.prototype.handle = function(request, response) {
|
||||
if (request.method == 'GET') {
|
||||
|
||||
}
|
||||
else if (request.method == 'POST') {
|
||||
var key = '123';
|
||||
request.on('data', function(data) {
|
||||
if (!documents[key]) {
|
||||
documents[key] = '';
|
||||
}
|
||||
documents[key] += data.toString();
|
||||
});
|
||||
request.on('end', function(end) {
|
||||
response.end(JSON.stringify({ uuid: key }));
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
///////////
|
||||
|
||||
http.createServer(function(request, response) {
|
||||
|
||||
var handler = new StaticHandler('./static');
|
||||
handler.handle(request, response);
|
||||
var incoming = url.parse(request.url, false);
|
||||
|
||||
if (incoming.pathname.indexOf('/documents') === 0) {
|
||||
var handler = new DocumentHandler();
|
||||
handler.handle(request, response);
|
||||
}
|
||||
else {
|
||||
var handler = new StaticHandler('./static');
|
||||
handler.handle(request, response);
|
||||
}
|
||||
|
||||
}).listen(7777);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue