A file sharing sample!
[1/1] from: koopmans::itr::ing::nl at: 15-Aug-2001 16:46
Too simple not to code.... now let's enhance it to Rebella ;-)
What does it do: file-server.r serves the list of files available in . or a
file in . It is a rugby server.
You should run it in a directory with some files.
Now run file-client.r in a different directory, click list files and then on
a file. Now inspect your directory. All stuff runs on your local machine.
Enjoy, and here it comes....
******* file-client.r *********
REBOL []
do read http://www.reboltech.com/library/scripts/rugby4.r
;Get the remote proxie funcs: list-files and get-file
do get-rugby-service tcp://localhost:8001
the-files: copy []
;This one shows the layout with one button!
;It fetches the file list
;And molds each element of the file list.
;So you can put it in a text list!
;Then it calls get-l2 that constructs a list of files
;CLicking a file writes it out locally!
l1: layout [ button "list-files"
[ the-files: list-files
forall the-files
[ change the-files remove mold first the-files]
the-files: head the-files
probe the-files
view get-l2
]
]
get-l2: does [ return layout compose
[ text-list data (the-files)
[
write/binary to-file value get-file value]
]
]
view l1
*******file-server.r **********************
REBOL []
do read http://www.reboltech.com/library/scripts/rugby4.r
list-files: does [ return read %. ]
get-file: func [ f ] [ return read/binary to-file f]
serve [ list-files get-file ]