Giter VIP home page Giter VIP logo

simplehttpserver's Introduction

simpleHTTPServer

A simple HTTP Server inspired by python's simpleHTTPServer but implemented in Go and compiled to a single executable + more features.

This project is under development but is already in a usable state!

The project was written in go1.21 and uses gorilla/mux under the hood.

Features

This is the roadmap for the project, you can already use the features if they are checked:

  • Interface for cURL and wget
  • Choosing a web root directory in the CLI interface
  • Accepting upload requests with curl -T <file>
  • Interface for browsers implemented in svelte (probably)
  • Zip compressing for multiple files
  • Tar compressing for multiple files (for machines that do not have zip installed)
  • TLS support
  • Basic authentication for downloading files
  • Basic authentication for uploading files
  • Server side GUI interface for easier use

Install

Releases

Check https://github.com/hacker-szabo/simpleHTTPServer/releases and download the .zip file for your operating system and architecture.

Using go installer

go1.21 is recommended

go install github.com/hacker-szabo/simpleHTTPServer@latest

Build

go1.21 is recommended

git clone https://github.com/hacker-szabo/simpleHTTPServer.git
cd simpleHTTPServer
go build simpleHTTPServer.go

Usage

Server side

Obtain the executable and optionally set it up in a PATH folder.

Just simply run it and it will serve the current directory on port 9000

simpleHTTPServer

You can change the port using -p:

simpleHTTPServer -p 8000

You can change the webroot with the -t parameter:

simpleHTTPServer -t ~/tmp/web

Client side

So far only CLI is supported, use any HTTP client, like cURL:

curl http://server_address:9000

It will return a file list of downloadable files with id numbers like so:

Download the file on: /id/<id_of_the_file>
0	
1	index.html
2	output
3	picture.jpg
4	test.bin

To download the file you can use either cURL or wget with the URL /id/<id_number_of_the_file>:

wget http://server_address:9000/id/3 -O picture.jpg

In the future, browser support will be available with a nice UI.

Upload a file to simpleHTTPServer

Navigate to the webroot and run the software:

simpleHTTPServer -u

Where the -u means that you enable the clients to send files to upload with the PUT method.

OR provide the webroot by the -t flag:

simpleHTTPServer -u -t <your_webroot>

On client side you need to send the file with the following command:

curl <yourserver>:<yourport>/upload/ -T <yourfile>

For example:

curl 127.0.0.1:9000/upload/ -T test.txt

You can also give a different filename and the server will write it into that file or overwrite the existing file:

curl 127.0.0.1:9000/upload/FILENAME_ON_SERVER.TXT -T test.txt

simplehttpserver's People

Contributors

hacker-szabo avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar

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.