|
1 | 1 | # MiniHTTPServer |
2 | | -Mini HTTP server for spinning HelpViewer quickly on local environments. Intended primarily for development purposes only, not for production deployment. |
| 2 | + |
| 3 | +Mini HTTP server for spinning HelpViewer quickly on local environments without changing standard CORS policy on browser apps. Intended primarily for development purposes only, not for production deployment. |
| 4 | + |
| 5 | +## Install |
| 6 | + |
| 7 | +1. Cloning this repository to your local machine |
| 8 | +2. OCI (Podman/Docker) image |
| 9 | + |
| 10 | +### Build locally |
| 11 | + |
| 12 | +This call will provide static build of source code (no external lib or binary dependencies). |
| 13 | + |
| 14 | +> CGO_ENABLED=0 \\ |
| 15 | +> go build -trimpath -ldflags="-s -w" -o main |
| 16 | +
|
| 17 | +The same approach is used for OCI image preparation by CI/CD pipeline. |
| 18 | + |
| 19 | +### OCI image |
| 20 | + |
| 21 | +Base : **scratch** |
| 22 | + |
| 23 | +Linux systems: |
| 24 | + |
| 25 | +> podman pull ghcr.io/HelpViewer/MiniHTTPServer |
| 26 | +> mkdir ./www |
| 27 | +> podman run -p 80:8080 -v ./www:/www ghcr.io/HelpViewer/MiniHTTPServer |
| 28 | +
|
| 29 | +Webserver is accessible from port **80** via your browser with use of your IP for external network (inside Podman network access via container alias and port 8080). |
| 30 | + |
| 31 | +## Use with local launch |
| 32 | + |
| 33 | +1. Run: |
| 34 | + - buid.bat (on Windows) |
| 35 | + - buid.sh (on Linux) |
| 36 | + |
| 37 | +2. Create directory **www** on the same level as **build** script |
| 38 | +3. Run ./main or .\main.exe |
| 39 | + |
| 40 | +### Parameters |
| 41 | + |
| 42 | +Parameters map: |
| 43 | +main --port [port] --dir [directory] --addr [IP address] |
| 44 | + |
| 45 | +| Parameter | Default | meaning | |
| 46 | +| --- | --- | --- | |
| 47 | +| **--port** | 8080 | HTTP port on which the server listens for requests | |
| 48 | +| **--dir** | www/ | The root directory with files to be served | |
| 49 | +| **--addr** | 127.0.0.1: | Binding IP address. | |
| 50 | + |
| 51 | +> [!CAUTION] |
| 52 | +> **--addr** parameter important notice: |
| 53 | +Value: **127.0.0.1:** (default) keeps the server published only within the computer. |
| 54 | +When you start the server with the value **:**, you publish the server to the connected network so that external computers can access your server. |
0 commit comments