Downloads from URL url_string and stores the returned data in the file local_name. Includes console feedback.
Example:
# Example for download
try
println download("https://example.com", "/tmp/example.html")
catch err
println "Download failed"
endtry
Converts HTML special characters to ampersand values.
Example:
# Example for html_escape
println html_escape("<div>Hello & Welcome</div>")
Converts a string containing ampersand values to include HTML special characters.
Example:
# Example for html_unescape
escaped = html_escape("<div>Hello & Welcome</div>")
println html_unescape(escaped)
newline separated list of device names.
Example:
# Example for net_interfaces println net_interfaces()
Set the number of requests between cache cleanups.
Example:
# Example for web_cache_cleanup_interval web_cache_cleanup_interval(60)
Enable or disable web caching globally.
Example:
# Example for web_cache_enable web_cache_enable(true)
Set the maximum age of cached entries in seconds.
Example:
# Example for web_cache_max_age web_cache_max_age(3600)
Set the maximum memory usage for cache in MB.
Example:
# Example for web_cache_max_memory web_cache_max_memory(1000000)
Set the maximum number of cached entries.
Example:
# Example for web_cache_max_size web_cache_max_size(1000000)
Manually purge all cached entries.
Example:
# Example for web_cache_purge web_cache_purge()
Return cache statistics: size, hits, misses, memory usage.
Example:
# Example for web_cache_stats println web_cache_stats()
Returns a string with content downloaded from loc_string.
Example:
# Example for web_custom
try
println web_custom("GET", "https://example.com")
catch err
println "Network error"
endtry
Show configured request routing.
Example:
# Example for web_display println web_display()
Downloads from URL url_string and stores the returned data in the file local_file.
Example:
# Example for web_download
try
println web_download("https://example.com", "/tmp/example.html")
catch err
println "Network error"
endtry
Returns a structure with content downloaded from loc_string. .result is the content string. .code is the status code.
Example:
# Example for web_get
try
println web_get("https://example.com").result
catch err
println "Network error"
endtry
Enable or disable gzip compression for responses.
Example:
# Example for web_gzip_enable web_gzip_enable(true)
Makes a HEAD request of the given loc_string. Returns true if retrieved successfully.
Example:
# Example for web_head
try
println web_head("https://example.com")
catch err
println "Network error"
endtry
(read-only) returns the maximum permitted client count for a web server.
Example:
# Example for web_max_clients println web_max_clients()
Perform a HTTP POST.
Example:
# Example for web_post
try
println web_post("https://example.com", ["key", "value"])
catch err
println "Network error"
endtry
Send HTTP request with custom method, headers, and raw body. Returns [body, headers, status_code].
Example:
# Example for web_raw_send
try
println web_raw_send("example.com", 80, "GET / HTTP/1.0\r\n\r\n")
catch err
println "Network error"
endtry
Returns a struct representing details of an inbound web request.
web_serve_decode() returns the following member fields:
.host (host:port), .method, .path, .remote (remote_ip:port) and .data (POST data).
Example:
# Example for web_serve_decode
var w={"host":"localhost:80","path":"/","data":"hi"}
println web_serve_decode(w) # struct fields
Write arguments to the web log file, if available.
Example:
# Example for web_serve_log println web_serve_log()
Set the throttle controls for web server logging.
Example:
# Example for web_serve_log_throttle web_serve_log_throttle(10, 20)
Provides a traffic routing instruction to a web server.
Example:
# Example for web_serve_path
try
id = web_serve_start("/tmp", 18080)
web_serve_path(id, "S", "/.*", "/index.html")
web_serve_stop(id)
catch err
println "Web server error"
endtry
Returns an identifier for a new http server.
Example:
# Example for web_serve_start
try
id = web_serve_start("/tmp", 18080)
println web_serve_up(id)
web_serve_stop(id)
catch err
println "Web server error"
endtry
Stops and discards a running http server.
Example:
# Example for web_serve_stop
try
id = web_serve_start("/tmp", 18080)
web_serve_stop(id)
catch err
println "Web server error"
endtry
Checks if a web server is still running.
Example:
# Example for web_serve_up
try
id = web_serve_start("/tmp", 18080)
println web_serve_up(id)
web_serve_stop(id)
catch err
println "Web server error"
endtry