aboutsummaryrefslogtreecommitdiff
path: root/src/browser.nim
diff options
context:
space:
mode:
Diffstat (limited to 'src/browser.nim')
-rw-r--r--src/browser.nim11
1 files changed, 6 insertions, 5 deletions
diff --git a/src/browser.nim b/src/browser.nim
index 97713a3..c8fdea8 100644
--- a/src/browser.nim
+++ b/src/browser.nim
@@ -1,21 +1,21 @@
-import std/strutils, protocols/http, html, uri
+import std/strutils, protocols/http, formats/[html, uri], gui/terminal
let url = "https://example.org:443/index.html"
# let url = paramStr(1)
-proc request(uri: string) =
+proc request*(uri: string) =
# This is probably the best place to implement scheme-specific stuff
let url = parseURL(uri)
case url.scheme:
of "http", "https":
let response = httpRequest(url)
- renderHTML(response.body)
+ render(parseHTML(response.body))
# Exercise: view-source
of "view-source":
# We must parse the url again without the view-source: prefix
let url = uri.split(':', maxsplit=1)[1]
let response = httpRequest(parseURL(url))
- renderSource(response.body)
+ renderSource(parseHTML((response.body)))
# Exercise: file:// scheme
of "file":
discard
@@ -25,7 +25,8 @@ proc request(uri: string) =
else:
raise newException(Exception, "Not a valid scheme: " & url.scheme)
-request(url)
+when isMainModule:
+ request(url)
# HTTP/1.1
# Compression