Skip to content

Commit b189872

Browse files
save file
1 parent 69fd3ad commit b189872

File tree

1 file changed

+17
-208
lines changed

1 file changed

+17
-208
lines changed

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

Lines changed: 17 additions & 208 deletions
Original file line numberDiff line numberDiff line change
@@ -3,240 +3,49 @@
33

44
<!DOCTYPE html>
55

6+
67
<html lang=en>
78

89
<head>
910
<meta charset=utf-8>
1011

1112
<title>
12-
file-server
13+
file-server.js
1314
</title>
1415

1516
<meta name=description content=''>
1617

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'>
1920

2021
<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+
2223

2324
<script src='https://libs.ext-code.com/js/dom/component/v3.0/component.js?hdr'></script>
2425

2526
<script>
2627

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+
3539
</script>
3640

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-
6541
</head>
6642

67-
6843
<body>
6944

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>
17546

17647
</body>
17748

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-
23749
</html>
23850

23951

240-
241-
242-

0 commit comments

Comments
 (0)