Fileserver: A simple static fileserver

Fileserver

A simple static fileserver. Serves requests to local files in a directory of your choosing so that you can preview files in your browser.

Behavior

When visiting a path in your browser, the fileserver will perform the following actions to determine what to respond with:

  1. If the path exists:
    1. If the path is a file, its contents are served
    2. If the path is a directory:
      1. If the directory contains a file named "index.html," that file's contents are served
      2. Otherwise, a default directory listing, containing a list of directory entries, is rendered
  2. If the path does not exist:
    1. If a file with the same name but a ".html" extension appended exists in the same directory, that file is served
    2. Otherwise, a page indicating that the file could not be found is rendered

Usage

The fileserver can be invoked from either the command line or the Go API. In both instances you can choose which port to bind the server to, and which directory to serve files from.

CLI

$ fileserver             # serves the current directory at localhost:4000
$ fileserver --port 3000 # serves the current directory at localhost:3000
$ fileserver ./documents # serves the ./documents directory at localhost:4000

Go

package main

import (
	"github.com/itsliamegan/fileserver"
)

func main() {
	root := "./"
	addr := "127.0.0.1:4000"

	fileserver.Start(root, addr)
}

Installation

  1. Clone the repository and cd into the directory
  2. Run go build
  3. Optionally, move the newly created fileserver executable to a directory in your PATH such as /usr/local/bin/
Similar Resources

a simple http server as replacement of python -m http.server

ser a simple http server as replacement of python -m http.server

Dec 5, 2022

Oogway is a simple web server with dynamic content generation and extendability in mind supporting a Git based workflow.

Oogway Oogway is a simple web server with dynamic content generation and extendability in mind supporting a Git based workflow. It's somewhere in betw

Nov 9, 2022

CasaOS - A simple, easy-to-use, elegant open-source home server system.

CasaOS - A simple, easy-to-use, elegant open-source home server system.

CasaOS - A simple, easy-to-use, elegant open-source home server system. CasaOS is an open-source home server system based on the Docker ecosystem and

Jan 8, 2023

Simple Golang Product API Server

Simple Golang Product API Server Layanan API untuk menambah, merubah informasi, mengambil data dan menghapus produk. Implementasi kode terinspirasi ol

Nov 20, 2022

A Simple Application written in go-lang that serves the index.html

go-web server A Simple Application written in go-lang that serves the index.html Running the Application, Well, make sure you have go installed to con

Nov 24, 2021

A simple server with REST API to keep track of your TODOs (with html interface).

A simple server with REST API to keep track of your TODOs (with html interface).

TODOserver A simple server written in GO using gin and gorm. Getting started Download the repository docker build -t todoserver . docker run -p 8888:8

Nov 10, 2021

A very simple Golang server handling basic GET and POST requests

GOLANG SERVER INTRO As a true Blockchain enthusiast, I had to learn Solidity and Golang to participate to several projects. This repository consists o

Nov 17, 2021

A simple Go HTTP server that proxies RPC provider requests

go-rpc-provider-proxy A simple Go HTTP server that proxies RPC provider requests.

Nov 21, 2021

Simple HTTP server written in golang

Simple HTTP server written in golang Simple webserver in golang, to demonstrate basic functionalities like e.g. sending back some request header info,

Aug 31, 2022
Static Content Web Server

Static Content Web Server The main purpose of the project is to develop static server that can be used with modern javascript frameworks (React, vue.j

Dec 17, 2021
Opinionated boilerplate Golang HTTP server with CORS, OPA, Prometheus, rate-limiter for API and static website.
Opinionated boilerplate Golang HTTP server with CORS, OPA, Prometheus, rate-limiter for API and static website.

Teal.Finance/Server Opinionated boilerplate HTTP server with CORS, OPA, Prometheus, rate-limiter… for API and static website. Origin This library was

Nov 3, 2022
A local server with real-time reload function designed for static website preview or development

中文 | English ?? 介绍 reserver 是一款为静态网站预览或开发设计的具有实时重新加载功能的本地服务器。 其主要运用场景为: 单页应用的预览(例如Vue编译之后的项目不可以直接通过file://协议进行访问) 具有ajax请求的页面(因浏览器安全限制,默认禁止file://协议进行

Aug 23, 2022
A simple http-web server logging incoming requests to stdout with simple http-interface.
A simple http-web server logging incoming requests to stdout with simple http-interface.

http-cli-echo-logger A simple http-web server logging incoming requests to stdout with simple http-interface. Run locally go run ./cmd/main.go Default

Jul 18, 2022
A simple SHOUTcast server.

DudelDu DudelDu is a simple audio/video streaming server using the SHOUTcast protocol. Features Supports various streaming clients: VLC, ServeStream,

Nov 20, 2022
Heart 💜A high performance Lua web server with a simple, powerful API
Heart 💜A high performance Lua web server with a simple, powerful API

Heart ?? A high performance Lua web server with a simple, powerful API. See the full documentation here. Overview Heart combines Go's fasthttp with Lu

Aug 31, 2022
KissLists is a very simple shared lists server
KissLists is a very simple shared lists server

KissLists is a very simple shared lists server. with mobile optimised design basic theme support websockets messages sqlite database but no

Nov 30, 2022
Simple webhook delivery system powered by Golang and PostgreSQL

postmand Simple webhook delivery system powered by Golang and PostgreSQL. Features Simple rest api with only three endpoints (webhooks/deliveries/deli

Dec 22, 2022
A simple HTTP Server to share files over WiFi via Qr Code
A simple HTTP Server to share files over WiFi via Qr Code

go-fileserver A simple HTTP server to share files over WiFi via QRCode Installation You can download compressed version from

Oct 8, 2022