URL shortener: Difference between revisions

m
m (syntax highlighting fixup automation)
m (→‎{{header|Wren}}: Minor tidy)
 
Line 982:
{{libheader|Wren-json}}
An embedded program with a Go host so we can use its net/http module.
<syntaxhighlight lang="ecmascriptwren">/* url_shortenerURL_shortener.wren */
 
import "./json" for JSON
Line 1,043:
}</syntaxhighlight>
We now embed this script in the following Go program and build it.
<syntaxhighlight lang="go">/* go build url_shortenerURL_shortener.go */
 
package main
Line 1,058:
type any = interface{}
 
var fileName = "url_shortenerURL_shortener.wren"
var host = "localhost:8000"
 
Line 1,158:
Sample output (abbreviated) including building and starting the server from Ubuntu 20.04 terminal and entering a valid and then an invalid shortened URL:
<pre>
$ go build url_shortenerURL_shortener.go
 
$ ./url_shortenerURL_shortener &
 
$ curl -X POST 'localhost:8000'/ \
9,476

edits