|
3 | 3 |
|
4 | 4 | <!DOCTYPE html> |
5 | 5 |
|
| 6 | + |
6 | 7 | <html lang=en> |
7 | 8 |
|
8 | 9 | <head> |
9 | 10 | <meta charset=utf-8> |
10 | 11 |
|
11 | 12 | <title> |
12 | | - file-server |
| 13 | + file-server.js |
13 | 14 | </title> |
14 | 15 |
|
15 | 16 | <meta name=description content=''> |
16 | 17 |
|
17 | | - <base href='https://ext-code.com/code/nodejs/servers/file-server/'> |
18 | | - <link rel=canonical href='https://ext-code.com/code/nodejs/servers/file-server/file-server.html'> |
| 18 | + <base href='https://ext-code.com/code/nodejs/server/file-server/file-server.html'> |
| 19 | + <link rel=canonical href='https://ext-code.com/code/nodejs/server/file-server/file-server.html'> |
19 | 20 |
|
20 | 21 | <meta name=viewport content='width=device-width, initial-scale=1'> |
21 | | - <link rel=icon href='data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAB4AAAAeCAMAAAAM7l6QAAABAlBMVEVHcEzwShbtTxrzbhXyoSHyORLyTRPzXxTzZxXzqB/upCjyRRP0ixfpOB31qBnyTxTvOBTtMBX1nhjxLBH1phr0nhvwMBPtNxb0hhfubRzzeBbyaxjxbBr0jBr0hRnyQhP0jhfzlBzzrB70gxbxPRP0kxjypiD0rBz0mRnzox/uKhLzfhjzoR3xPRPzmRn0kxjvKhPwMhL1oxnwMxP1oxryWBXyeRnxXRfzfRbyfhryVxXycxfybRjwchrzbRXxeBnyaRjzchbyYxbzYhXxXxfzaBbtKxTuKhP0qx3zrB7xZhrxZhn1pRjxMBHzUhPyRRP0jhf0iBf0kxf1mRj0gxb0fRW9Ofp/AAAATHRSTlMAHxH+EP3g/f42CIF/CPZ/izb89ruLuyjgG/x/Ux8f3+AeWoDO3yB4ziV4eyuzs4JL6+vQ0HtYWOUk5dGMRfFnjOjR6GjxWlpLS0VFZBEF4QAAATVJREFUKM+tk9eygjAURaWJoFgREOy9997rrYD9/3/lwsCEBJ/ujDztlcXsk4TB43nHg3frH5wVuc96F0dtRIhpsYidjShEYCsONK0nYBZgQk/TBiKkwxQVFkEhLpoMDS5SLQ5u41pU0RmPZc5+dC/+cwZztPdVe2Gth1Ad0v+h5/oI1SN97ugjTU9QPaHpo32qX+VA7xOoTuzpg/Jjnm3r8/lOSfc3SJ6M5a0RlgRBrF/12lhemuUrZUcs3OULYqes7IvbyPIY1WNZ3gCYTZ8NVDee0xmAtPQooLrwkNIAUtI1gOrAFdbZi1tfsikAudKtg+rOrZQDQFbvbRa2bPteJR2MR6PxJmCyaTL0dm2oqn2+bEGZ76vqsAa3MXxQDTJ2NiLPoHshvyp5ezybr3yTb/m3/gB3/SLZj0tcfgAAAABJRU5ErkJggg=='> |
| 22 | + |
22 | 23 |
|
23 | 24 | <script src='https://libs.ext-code.com/js/dom/component/v3.0/component.js?hdr'></script> |
24 | 25 |
|
25 | 26 | <script> |
26 | 27 |
|
27 | | - |
28 | | - function start(){ |
29 | | - debug('start'); |
30 | | - initdom(); |
31 | | - |
32 | | - }//start |
33 | | - |
34 | | - |
| 28 | + var path = 'nodejs/server/file-server/'; |
| 29 | + var filename = 'file-server.js'; |
| 30 | + var date = '2026-02-17'; |
| 31 | + var files = { |
| 32 | + 'source' : { |
| 33 | + 'latest' : null, |
| 34 | + }, |
| 35 | + 'examples' : { |
| 36 | + }, |
| 37 | + }; |
| 38 | + |
35 | 39 | </script> |
36 | 40 |
|
37 | | - <style> |
38 | | - |
39 | | - html |
40 | | - {font-family:arial} |
41 | | - |
42 | | - |
43 | | - #hdr |
44 | | - {display:flex;justify-content:space-between} |
45 | | - #hdr>div:first-of-type |
46 | | - {display:flex;gap:20px} |
47 | | - |
48 | | - code |
49 | | - {display:block;white-space:pre;font-family:monospace;margin:20px;padding:20px;background:whitesmoke} |
50 | | - |
51 | | - |
52 | | - |
53 | | - web-editor |
54 | | - {display:block;height:200px;margin:20px;border:1px solid lightgray;padding:10px} |
55 | | - |
56 | | - |
57 | | - input |
58 | | - {font-size:16px;padding:5px 10px} |
59 | | - input[type=button] |
60 | | - {cursor:pointer} |
61 | | - |
62 | | - |
63 | | - </style> |
64 | | - |
65 | 41 | </head> |
66 | 42 |
|
67 | | - |
68 | 43 | <body> |
69 | 44 |
|
70 | | - |
71 | | - <div id=hdr> |
72 | | - |
73 | | - <div> |
74 | | - <a href='https://ext-code.com/'> |
75 | | - home |
76 | | - </a> |
77 | | - |
78 | | - <a href='../../code.html'> |
79 | | - code |
80 | | - </a> |
81 | | - </div> |
82 | | - |
83 | | - <h1> |
84 | | - file-server |
85 | | - </h1> |
86 | | - |
87 | | - <div> |
88 | | - 19 Dec 2025 |
89 | | - </div> |
90 | | - |
91 | | - </div hdr> |
92 | | - |
93 | | - |
94 | | - <div> |
95 | | - |
96 | | - |
97 | | - <p> |
98 | | - This code module implements a lightweight HTTPS server that exposes direct file system operations to the browser through a simple fetch‑based API. By sending requests such as |
99 | | - </p> |
100 | | - |
101 | | - <div> |
102 | | - <input value=download type=button> |
103 | | - </div> |
104 | | - |
105 | | - <code> |
106 | | - |
107 | | - fetch("https://localhost:3000/a.txt", { headers: { mode: "load" } }) |
108 | | - |
109 | | - </code> |
110 | | - |
111 | | - <p> |
112 | | - the browser can interact with local files securely and consistently. |
113 | | - </p> |
114 | | - |
115 | | - <p> |
116 | | - Supported operations include: |
117 | | - </p> |
118 | | - |
119 | | - <p> |
120 | | - load → retrieve file contents |
121 | | - </p> |
122 | | - |
123 | | - <p> |
124 | | - save → write or overwrite file data |
125 | | - </p> |
126 | | - |
127 | | - <p> |
128 | | - file delete → remove a file |
129 | | - </p> |
130 | | - |
131 | | - <p> |
132 | | - dir read → list directory contents |
133 | | - </p> |
134 | | - |
135 | | - <p> |
136 | | - dir create → make a new directory |
137 | | - </p> |
138 | | - |
139 | | - <p> |
140 | | - dir delete → remove a directory |
141 | | - </p> |
142 | | - |
143 | | - <p> |
144 | | - Together, these commands provide a complete set of standard file I/O capabilities accessible from the browser. This member sits at the Code stage of the pipeline: more substantial than a library, since it defines a working server with a defined protocol, but not yet a full project. It serves as a foundation for building browser‑driven file management tools, developer utilities, or experimental web‑native applications. |
145 | | - </p> |
146 | | - |
147 | | - </div> |
148 | | - |
149 | | - <web-editor component h=200> |
150 | | - |
151 | | - [ not implemented yet ] |
152 | | - |
153 | | - </web-editor> |
154 | | - |
155 | | - <div> |
156 | | - |
157 | | - <p> |
158 | | - the client side library can found at |
159 | | - </p> |
160 | | - |
161 | | - </div> |
162 | | - |
163 | | - <div> |
164 | | - |
165 | | - <a href='/libs/js/io/file-server/file-server.html'> |
166 | | - file-server |
167 | | - <span class=link-domain> |
168 | | - ext-code.com |
169 | | - </span> |
170 | | - </a> |
171 | | - |
172 | | - </div> |
173 | | - |
174 | | - |
| 45 | + <page-html v1.0 component=grp2 style='display:block'></page-html> |
175 | 46 |
|
176 | 47 | </body> |
177 | 48 |
|
178 | | - <script> |
179 | | - |
180 | | - |
181 | | - var jszip; |
182 | | - |
183 | | - |
184 | | - var btn = {}; |
185 | | - |
186 | | - |
187 | | - //: |
188 | | - |
189 | | - |
190 | | - function initdom(){ |
191 | | - |
192 | | - $('[value=download]').onclick = btn.download; |
193 | | - |
194 | | - }//initdom |
195 | | - |
196 | | - |
197 | | - //: |
198 | | - |
199 | | - |
200 | | - btn.download = async function(){ |
201 | | - |
202 | | - if(!jszip){ |
203 | | - jszip = await import('https://cdn.jsdelivr.net/npm/jszip/+esm'); |
204 | | - jszip = jszip.default; |
205 | | - } |
206 | | - |
207 | | - var zip = new jszip(); |
208 | | - zip.folder(`file-server`); |
209 | | - |
210 | | - var res = await fetch('https://raw.githubusercontent.com/javascript-2020/code/main/nodejs/server/file-server/file-server.js'); |
211 | | - var blob = await res.blob(); |
212 | | - zip.file(`file-server/file-server.js`,blob); |
213 | | - |
214 | | - zip.folder(`file-server/node_modules`); |
215 | | - |
216 | | - var res = await fetch('https://raw.githubusercontent.com/javascript-2020/libs/main/js/string/getmime/getmime.js'); |
217 | | - var blob = await res.blob(); |
218 | | - zip.file(`file-server/node_modules/getmime.js`,blob); |
219 | | - |
220 | | - var res = await fetch('https://raw.githubusercontent.com/javascript-2020/libs/main/nodejs/keys/keys.js'); |
221 | | - var blob = await res.blob(); |
222 | | - zip.file(`file-server/node_modules/keys.js`,blob); |
223 | | - |
224 | | - var blob = await zip.generateAsync({type:'blob'}); |
225 | | - |
226 | | - var url = window.URL.createObjectURL(blob); |
227 | | - var a = document.createElement('a'); |
228 | | - a.download = 'file-server'; |
229 | | - a.href = url; |
230 | | - a.click(); |
231 | | - |
232 | | - }//download |
233 | | - |
234 | | - |
235 | | - </script> |
236 | | - |
237 | 49 | </html> |
238 | 50 |
|
239 | 51 |
|
240 | | - |
241 | | - |
242 | | - |
0 commit comments