Skip to content

A bare minimum web server that only serves static files over the internet

License

Notifications You must be signed in to change notification settings

junekimdev/gostaticserver

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Static Web Server

A bare minimum web server that only serves static files over the internet

Install

git clone https://github.com/junekimdev/gostaticserver.git staticserver
cd staticserver
mkdir public

Build

Building Go directly

This will build an executable file in the working directory

go build -o main

Using Docker (Recommended)

This will build a docker image

# shortest
make

# Same as above
make build

# Without cache
make bf

Use

Without building compiling Go

go run ./main.go

With compiled file from go build

./main

With Docker image

make up

Add & Serve

Add files

  1. Create a directory named public in the working directory
  2. Put files in ./public

files in ./public can be accessed via https://mydomain.com/myfile.ext

Add directories

  1. Create directories in ./public
  2. Add files in the created directory

files in ./public/mydir can be accessed via https://mydomain.com/mydir/myfile.ext

⚠️ Accessing the directory requires index.html in the said directory

index.html in ./public/mydir will be accessed via https://mydomain.com/mydir

404

If client tries to access a file that is not in the server, the server will return 404

About

A bare minimum web server that only serves static files over the internet

Resources

License

Stars

Watchers

Forks

Packages

No packages published