1 | static S serveTextFile(S uri, S name) {
|
2 | //print("sts: " + quote(uri));
|
3 | S prefix = "/download/"; |
4 | if (swic(uri, prefix)) {
|
5 | uri = dropFirst(l(prefix), uri); |
6 | //print("sts: " + quote(uri));
|
7 | if (eqic(name, uri)) {
|
8 | S content = loadProgramTextFile(name); |
9 | if (content == null) content = "<not found>"; |
10 | if (empty(content)) content = "<empty>"; |
11 | //print("sts content length: " + l(content));
|
12 | ret htmlencode(content); // hm. content-type? |
13 | } |
14 | } |
15 | ret null; |
16 | } |
download show line numbers debug dex old transpilations
Travelled to 13 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
| Snippet ID: | #1003044 |
| Snippet name: | serveTextFile - serve one of current bot's files through http |
| Eternal ID of this version: | #1003044/1 |
| Text MD5: | 5f8ec3ed0e8cfbad77353d999db2adca |
| Author: | stefan |
| Category: | eleu |
| Type: | JavaX fragment (include) |
| Public (visible to everyone): | Yes |
| Archived (hidden from active list): | No |
| Created/modified: | 2016-04-25 15:15:23 |
| Source code size: | 512 bytes / 16 lines |
| Pitched / IR pitched: | No / No |
| Views / Downloads: | 741 / 723 |
| Referenced in: | [show references] |