Giter VIP home page Giter VIP logo

gowebhello's Introduction

license Go Report Card

gowebhello

gowebhello is a simple golang replacement for 'python -m SimpleHTTPServer'. gowebhello can also be configured as an HTTPS web server using SSL certificates.

Usage

HTTPS

If you want to use TLS, you will need a certificate:

$ openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout key.pem -out cert.pem

Building

Without Modules, before Go 1.11

# make sure GOPATH is either unset or properly set
go get github.com/udhos/gowebhello
go install github.com/udhos/gowebhello

With Modules, starting from Go 1.11

git clone https://github.com/udhos/gowebhello ;# clone outside of GOPATH
cd gowebhello
go install ./gowebhello

Running

Use the '-h' switch to get command line help.

$ gowebhello -h

Example with TLS

Enable TLS by providing a certificate. If you enable TLS, HTTP port will be redirected to HTTPS port.

$ ~/go/bin/gowebhello
2017/06/08 11:24:03 registering static directory /home/lab/go/src/github.com/udhos/gowebhello as www path /www/
2017/06/08 11:24:03 using TCP ports HTTP=:8080 HTTPS=:8443 TLS=true
2017/06/08 11:24:03 installing redirect from HTTP=:8080 to HTTPS=8443
2017/06/08 11:24:03 serving HTTPS on TCP :8443

Then open https://localhost:8443

Example without TLS

If you do not provide a certificate, TLS will be disabled.

$ ~/go/bin/gowebhello -cert=badcert
2017/06/08 11:25:01 TLS cert file not found: badcert - disabling TLS
2017/06/08 11:25:01 registering static directory /home/lab/go/src/github.com/udhos/gowebhello as www path /www/
2017/06/08 11:25:01 using TCP ports HTTP=:8080 HTTPS=:8443 TLS=false
2017/06/08 11:25:01 serving HTTP on TCP :8080

Then open http://localhost:8080

Example with HTTPS only

You can disable HTTP by specifying the same port to both -addr and -httpsAddr.

$ ~/go/bin/gowebhello -addr :8443 -httpsAddr :8443
2017/06/08 11:25:46 registering static directory /home/lab/go/src/github.com/udhos/gowebhello as www path /www/
2017/06/08 11:25:46 using TCP ports HTTP=:8443 HTTPS=:8443 TLS=true
2017/06/08 11:25:46 serving HTTPS on TCP :8443

Container image

Find a small container image for gowebhello as udhos/web-scratch here:

https://hub.docker.com/r/udhos/web-scratch

or modify the Dockerfile, and build your own custom image

git clone https://github.com/brownchow/gowebhello.git
cd gowebhello
docker  build .  -t  udhos/web-scratch:v0.x

and run it

docker container run  -p 8080:8080  udhos/gowebhello:v0.x

END

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.