Run your small or test project server by golang.
- golang web server
- support .js file
- hot reload
- git clone https://github.com/madeinfree/simple-go-web-server
- cd simple-go-web-server
- alias simple-go-web-server='$(pwd)/bin/simple-go-web-server'
- go to your website project directory
- command
simple-go-web-server [options]
- open http://localhost:3000
Options | Type | Description | Default |
---|---|---|---|
--port, -p | int | setting web server listen port | 3000 |
--content, -c | string | setting hot loader file content base | null |
--hot, -hh | boolean | should required when you use --content options | false |
When you would like to set your website port you can command
simple-go-web-server -p 8080
to use 8080 port.
simple go web server help allow you to use hot reload, you can command
$ simple-go-web-server -p 1234 -c "/build/bundle.js" --hot
and copy below script paste in your js file
setInterval(() => {
fetch('http://localhost:3000/simple-go-server-file-change').then((r) => {
r.json().then((rr) => {
if (rr) {
fetch('http://localhost:3000//simple-go-server-file-callback?isOK=true', {
method: 'GET'
})
location.reload()
}
})
})
}, 2000)