Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Latest commit

 

History

History
History
131 lines (119 loc) · 3.8 KB

File metadata and controls

131 lines (119 loc) · 3.8 KB
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
module.exports = function (app, logger, event, fs, uuid) {
logger.info('module main');
var assert = require('assert');
app.get('/test', function (req, res) {
res.send('Hello this is the Openfpgaduino!');
});
app.post('/', function (req, res) {
res.statusCode = 302;
res.setHeader("Location", "index.html");
res.end();
});
var path = require('path');
app.get('/uuid', function (req, res) {
res.json(uuid)
});
function service_discover(urlstack, basebath) {
var table = []
for (var key in urlstack) {
if (urlstack.hasOwnProperty(key)) {
var val = urlstack[key];
if (val.route) {
val = val.route;
var url = {};
url[val.stack[0].method] = basebath + val.path;
table.push(url);
}
else if (val.handle.stack) {
var stack = val.handle.stack
var path = "/" + val.regexp.toString().match(/\\\/(.*)\\.*/m)[1]
table.push(service_discover(stack, path))
}
}
}
return table
}
app.get('/service', function (req, res) {
var urlstack = app._router.stack
//console.dir(urlstack)
res.json(service_discover(urlstack, "/"))
});
app.get('/list', function (req, res) {
var filelist = [];
fs.readdirAsync(__dirname + "/")
.then(function (list) {
list.forEach(function (filename) {
if (!/\.js$/.test(filename)) {
return;
}
filelist.push(filename);
})
res.json({
script: filelist
});
})
.catch(function (error) {
res.json({
error: error
});
})
});
app.get('/get/:filename', function (req, res) {
var filename = req.params.filename;
fs.readFileAsync(__dirname + "/" + filename, "utf8")
.then(function (code) {
res.send(code);
})
.catch(function (error) {
res.json({
error: error
});
})
});
app.post('/log', function (req, res) {
var length = parseInt(req.body.length);
var position = parseInt(req.body.position);
fs.openAsync("server.log", 'r')
.then(function (fd) {
var buffer = new Buffer(length);
return fs.readAsync(fd, buffer, 0, length, position)
})
.spread(function (bytes, data) {
res.json({
log: data.toString(),
length: bytes
});
})
.catch(function (error) {
res.json({
error: error
});
})
});
app.post('/install', function (req, res) {
var filename = req.body.filename;
var code = req.body.code;
fs.writeFileAsync(__dirname + "/" + filename, code)
.then(function () {
res.json({
message: 'app installed'
});
})
});
app.post('/load', function (req, res) {
var filename = req.body.filename;
event.emit('load', filename);
res.json({
message: 'app load'
});
});
app.del('/:filename', function (req, res) {
var filename = req.params.filename;
fs.unlinkAsync(__dirname + "/" + filename)
.then(function () {
res.json({
message: filename + ' deleted'
});
})
});
}
Morty Proxy This is a proxified and sanitized view of the page, visit original site.