Skip to content

Commit 1dc2899

Browse files
save file
1 parent 46a7334 commit 1dc2899

File tree

1 file changed

+83
-0
lines changed

1 file changed

+83
-0
lines changed

code/nodedjs/servers/file-server/file-server.html

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,13 @@
1919
<script>
2020

2121

22+
function start(){
23+
debug('start');
24+
initdom();
25+
26+
}//start
27+
28+
2229
</script>
2330

2431
<style>
@@ -36,6 +43,17 @@
3643
{display:block;white-space:pre;font-family:monospace;margin:20px;padding:20px;background:whitesmoke}
3744

3845

46+
47+
web-editor
48+
{display:block;height:200px;margin:20px;border:1px solid lightgray;padding:10px}
49+
50+
51+
input
52+
{font-size:16px;padding:5px 10px}
53+
input[type=button]
54+
{cursor:pointer}
55+
56+
3957
</style>
4058

4159
</head>
@@ -74,6 +92,10 @@ <h1>
7492
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
7593
</p>
7694

95+
<div>
96+
<input value=download type=button>
97+
</div>
98+
7799
<code>
78100

79101
fetch("https://localhost:3000/a.txt", { headers: { mode: "load" } })
@@ -116,12 +138,73 @@ <h1>
116138
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.
117139
</p>
118140

141+
</div>
142+
143+
<web-editor component h=200>
144+
145+
[ not implemented yet ]
119146

147+
</web-editor>
148+
120149
</body>
121150

122151
<script>
123152

124153

154+
var jszip;
155+
156+
157+
var btn = {};
158+
159+
160+
//:
161+
162+
163+
function initdom(){
164+
165+
$('[value=download]').onclick = btn.download;
166+
167+
}//initdom
168+
169+
170+
//:
171+
172+
173+
btn.download = async function(){
174+
175+
if(!jszip){
176+
jszip = await import('https://cdn.jsdelivr.net/npm/jszip/+esm');
177+
jszip = jszip.default;
178+
}
179+
180+
var zip = new jszip();
181+
zip.folder(`file-server`);
182+
183+
var res = await fetch('https://raw.githubusercontent.com/javascript-2020/code/main/nodejs/server/file-server/file-server.js');
184+
var blob = await res.blob();
185+
zip.file(`file-server/file-server.js`,blob);
186+
187+
zip.folder(`file-server/node_modules`);
188+
189+
var res = await fetch('https://raw.githubusercontent.com/javascript-2020/libs/main/js/string/getmime/getmime.js');
190+
var blob = await res.blob();
191+
zip.file(`file-server/node_modules/getmime.js`,blob);
192+
193+
var res = await fetch('https://raw.githubusercontent.com/javascript-2020/libs/main/nodejs/keys/keys.js');
194+
var blob = await res.blob();
195+
zip.file(`file-server/node_modules/keys.js`,blob);
196+
197+
var blob = await zip.generateAsync({type:'blob'});
198+
199+
var url = window.URL.createObjectURL(blob);
200+
var a = document.createElement('a');
201+
a.download = 'file-server';
202+
a.href = url;
203+
a.click();
204+
205+
}//download
206+
207+
125208
</script>
126209

127210
</html>

0 commit comments

Comments
 (0)