Download Jar. Libraryless. Click here for Pure Java version (5344L/30K).
1 | // hosts .html and .txt |
2 | |
3 | !7 |
4 | |
5 | static File dir; |
6 | |
7 | p { dir = javaxDataDir("Static Web Pages"); }
|
8 | |
9 | html {
|
10 | uri = dropSlashPrefix(uri); |
11 | |
12 | if (eq(uri, "upload")) {
|
13 | S text = params.get("text");
|
14 | S name; |
15 | |
16 | if (text != null) {
|
17 | name = uniqueFileNameUsingMD5_80_v2(text, md5(text)) + ".txt"; |
18 | saveTextFile(newFile(dir, name), text); |
19 | } else {
|
20 | S html = params.get("html");
|
21 | S title = dropAllTags(html); |
22 | name = uniqueFileNameUsingMD5_80_v2(title, md5(html)) + ".html"; |
23 | saveTextFile(newFile(dir, name), html); |
24 | } |
25 | ret "Saved as: " + ahref(rawSelfLink(urlencode(name)), name); |
26 | } |
27 | |
28 | if (empty(uri)) ret "Static pages bot"; |
29 | |
30 | S name = urldecode(uri); |
31 | if (!isProperFileName_allowSpaces(name)) |
32 | ret subBot_serve404("Invalid file name");
|
33 | |
34 | File f = newFile(dir, name); |
35 | ret serveTextOrHTML(f); |
36 | } |
download show line numbers debug dex old transpilations
Travelled to 13 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, irmadwmeruwu, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt
No comments. add comment
| Snippet ID: | #1017992 |
| Snippet name: | Static Pages Bot |
| Eternal ID of this version: | #1017992/12 |
| Text MD5: | add15614bc0452d98a137994cdb63c0c |
| Transpilation MD5: | aecbe9e0f4aea59af69019981a1af9bd |
| Author: | stefan |
| Category: | javax / web bots |
| Type: | JavaX source code (desktop) |
| Public (visible to everyone): | Yes |
| Archived (hidden from active list): | No |
| Created/modified: | 2021-09-23 00:18:32 |
| Source code size: | 888 bytes / 36 lines |
| Pitched / IR pitched: | No / No |
| Views / Downloads: | 738 / 2563 |
| Version history: | 11 change(s) |
| Referenced in: | [show references] |