File tree Expand file tree Collapse file tree 3 files changed +52
-20
lines changed Expand file tree Collapse file tree 3 files changed +52
-20
lines changed Original file line number Diff line number Diff line change @@ -35,7 +35,7 @@ install-examples: .lastinstall-examples
35
35
done
36
36
date > $@
37
37
38
- .lastinstall-examples : $(EXOBJS )
38
+ .lastinstall-examples : $(EXOBJS ) examples/help.html
39
39
for src in $? ; do \
40
40
$(AMPY ) put $$ src ` basename $$ src` ; \
41
41
done
Original file line number Diff line number Diff line change 18
18
19
19
app = Noggin ()
20
20
21
- helptext = '''<html>
22
-
23
- <h1>Simple file operations</h1>
24
-
25
- <ul>
26
- <li><a href="/disk"><code>GET /disk</code></a> to get filesystem
27
- information</li>
28
- <li><a href="/disk/free"><code>GET /disk/free</code></a> to get information
29
- about available disk space</li>
30
- <li><a href="/file"><code>GET /file</code></a> to list available files</li>
31
- <li><code>GET /file/<path></code> to get a file (for example,
32
- <a href="/file/boot.py">boot.py</a>)</li>
33
- <li><code>PUT /file/<path></code> to write a file</li>
34
- <li><code>POST /file/<path></code> to rename a file (new name is
35
- <code>POST</code> body)</li>
36
- <li><code>DELETE /file/<path></code> to delete a file</li>
37
- </ul>
38
- </html>'''
21
+
22
+ def chunked_iter (path ):
23
+ buf = bytearray (256 )
24
+ try :
25
+ with open (path ) as fd :
26
+ while True :
27
+ nb = fd .readinto (buf )
28
+ if not nb :
29
+ break
30
+ yield buf [:nb ]
31
+ except OSError :
32
+ raise HTTPError (404 )
39
33
40
34
41
35
@app .route ('/' )
42
36
def index (req ):
43
- return Response (content = helptext , mimetype = 'text/html' )
37
+ return Response (content = chunked_iter ('help.html' ),
38
+ mimetype = 'text/html' )
44
39
45
40
46
41
def get_statvfs ():
Original file line number Diff line number Diff line change
1
+ < html >
2
+
3
+ < h1 > Simple file operations</ h1 >
4
+
5
+ < ul >
6
+ < li > < a href ="/disk "> < code > GET /disk</ code > </ a > to get filesystem
7
+ information</ li >
8
+ < li > < a href ="/disk/free "> < code > GET /disk/free</ code > </ a > to get information
9
+ about available disk space</ li >
10
+ < li > < a href ="/file "> < code > GET /file</ code > </ a > to list available files</ li >
11
+ < li > < code > GET /file/<path></ code > to get a file (for example,
12
+ < a href ="/file/boot.py "> boot.py</ a > )</ li >
13
+ < li > < code > PUT /file/<path></ code > to write a file</ li >
14
+ < li > < code > POST /file/<path></ code > to rename a file (new name is
15
+ < code > POST</ code > body)</ li >
16
+ < li > < code > DELETE /file/<path></ code > to delete a file</ li >
17
+ </ ul >
18
+
19
+ < h2 > Non-file related</ h2 >
20
+
21
+ < ul >
22
+ < li > < a href ="/mem/free "> < code > GET /mem/free</ code > </ a > for available
23
+ memory</ li >
24
+ < li > < a href ="/net/eth0 "> < code > GET /net/eth0</ code > </ a > for information about
25
+ the wireless client interface</ li >
26
+ < li > < a href ="/net/eth1 "> < code > GET /net/eth1</ code > </ a > for information about
27
+ the wireless ap interface</ li >
28
+ < li > < a href ="/reset "> < code > GET /reset</ code > </ a > to reset the
29
+ board by calling < code > machine.reset</ code >
30
+ </ ul >
31
+
32
+ < p > For either of the < code > /net/...</ code > enpoints above, you can
33
+ request a specific key by adding another component to the URL. For
34
+ example, < a href ="/net/eth0/mac "> < code > GET
35
+ /net/eth0/mac</ code > </ a > .</ p >
36
+ </ html >
37
+
You can’t perform that action at this time.
0 commit comments