IS there a list archive? I have been lookiing for one.

I think this question may have already been answerd.

I get the following error:

REBOL
1.0.3.3 (Win32 x86)
TM & Copyright 1998 REBOL Technologies Inc.  All rights reserved.
Send bugs to [EMAIL PROTECTED]
Loading C:/Downloads/rebol-1_0_3_3/rebol-1.0.3/rebol.r...
Loading script C:/DOWNLO~1/REBOL-~1/REBOL-~1.3/BS.R

ERROR discovered in function do:
Word (open) (line 17)  has no value
REBOL top level.
>> 

With the following code:

REBOL [
    Title: "Micro Web Server"
    Date:  24-June-1999
    Purpose: "A tiny web server for HTML and images."
    File:  %webserver.r
    Notes: {
        Here is a simple little web server that works quite
        well. It's also small and easy to enhance and
        maintain. Set the web-dir to point to the file
        directory that contains your web site files, such as
        index.html.
    }
]

web-dir: %.   ; the path to where you store your web files

listen-port: open/lines tcp://:80  ; port used for web connections

errors: [
    400 "Forbidden" "No permission to access:"
    404 "Not Found" "File was not found:"
]

send-error: function [err-num file] [err] [
    err: find errors err-num
    insert http-port join "HTTP/1.0 " [
        err-num " " err/2 "^/Content-type: text/html^/^/" 
        <HTML> <TITLE> err/2 </TITLE>
        "<BODY><H1>SERVER-ERROR</H1><P>REBOL Webserver Error:"
        err/3 " " file newline <P> </BODY> </HTML>
    ]
]

send-page: func [data mime] [
    insert data rejoin ["HTTP/1.0 200 OK^/Content-type: " mime "^/^/"]
    write-io http-port data length? data
] 

while [on] [
    http-port: first wait listen-port
    request: first http-port
    file: "index.html"
    mime: "text/plain"
    parse request ["get" ["http" | "/ " | copy file to " "]]
    parse file [thru "." [
            "html" (mime: "text/html") |
            "gif"  (mime: "image/gif") |
            "jpg"  (mime: "image/jpeg")
        ]
    ]
    print ["retrieving:" file]
    any [
        if not exists? web-dir/:file [send-error 404 file]
        if error? try [data: read/binary web-dir/:file] [send-error 400
file]
        send-page data mime
    ]
    close http-port
]


Regards,

Richard Hughes

Reply via email to