diff options
| -rw-r--r-- | examples/http-server/http-server.tm | 12 | ||||
| -rwxr-xr-x | examples/http-server/sample-site/random.tm | 14 |
2 files changed, 14 insertions, 12 deletions
diff --git a/examples/http-server/http-server.tm b/examples/http-server/http-server.tm index 4cdbda4e..f7338b91 100644 --- a/examples/http-server/http-server.tm +++ b/examples/http-server/http-server.tm @@ -106,17 +106,7 @@ enum RouteEntry(ServeFile(file:Path), Redirect(destination:Text)): func respond(entry:RouteEntry, request:HTTPRequest -> HTTPResponse): when entry is ServeFile(file): body := if file:can_execute(): - output := Command(Text(file)):get_output()! - " - <!DOCTYPE HTML> - <html> - <head><title>$file</title></head> - <body> - <h1>$file program output</h1> - <pre>$output</pre> - </body> - </html> - " + Command(Text(file)):get_output()! else: file:read()! return HTTPResponse(body, content_type=_content_type(file)) diff --git a/examples/http-server/sample-site/random.tm b/examples/http-server/sample-site/random.tm index 7d183ee9..502618e8 100755 --- a/examples/http-server/sample-site/random.tm +++ b/examples/http-server/sample-site/random.tm @@ -2,4 +2,16 @@ use random func main(): - say("Random: $(random:int(1,100))") + say(" + <!DOCTYPE HTML> + <html> + <head> + <title>Random Number</title> + <link rel="stylesheet" href="styles.css"> + </head> + <body> + <h1>Random Number</h1> + Your random number is: $(random:int(1,100)) + </body> + </html> + ") |
