Tupi is a very simple http server. Its main purpose is to provide an easy way to serve files from, and upload file to, a directory.
Tupi is written in go so you need the go compiler installed. With that installed clone the code:
$ git clone https://github.com/jucacrispim/tupi
And install the program with:
$ cd tupi
$ make install
For all make targets use ``make help``
Tupi was created to serve and upload files to a directory. So first lets create a directory with files
$ mkdir myfiles
$ echo "My first file" > myfiles/file.txt
You can start the server using the command tupi
$ tupi -root myfiles
This is going to serve the files in the myfiles
directory and the server
will listen in the port 8080
Use the option -h
for all the options for tupi.
$ tupi -h
With the server running we can fetch files from the directory.
$ curl http://localhost:8080/file.txt
My first file
You can also list the contents of a directory:
$ curl http://localhost:8080/
<pre>
<a href="file.txt">file.txt</a>
</pre>
You can also, instead of listing the contents of a directory, return the
index.html file in it. To do so use the option default-to-index
.
$ tupi -default-to-index
To upload files is required an authenticated request using basic http auth. Tupi reads the user auth information from a htpasswd file. To create a htpasswd file use:
$ htpasswd -c -B /my/htpasswd myusername
And start tupi with the -htpasswd
flag:
$ tupi -root myfiles -htpasswd /my/htpasswd
Warning
Your htpasswd file MUST NOT be within the root directory being served by tupi
Now you can upload files sending a POST request to the "/u/" path in the server.
The request must have the multipart/form-data
Content-Type header and the
file must be in a input named file
.
$ curl --user test:123 -F 'file=@/home/juca/powerreplica.jpg' http://localhost:8080/u/
powerreplica.jpg
$ curl http://localhost:8080/
<pre>
<a href="file.txt">file.txt</a>
<a href="powerreplica.jpg">powerreplica.jpg</a>
</pre>
Tupi is capable of extracting .tar.gz
files. To extract files you send a
POST request to the "/e/" path in the server. This request must also have the
multipart/form-data
Content-Type header and the file must be in a
input named file
.
$ curl --user test:123 -F 'file=@/home/juca/test.tar.gz' http://localhost:8080/e/
bla/
bla/two.txt
bla/ble/
bla/ble/four.txt
bla/ble/bad.txt
bla/ble/three.txt
bla/one.txt
$ curl http://localhost:8080/
<pre>
<a href="bla/">bla/</a>
<a href="file.txt">file.txt</a>
<a href="powerreplica.jpg">powerreplica.jpg</a>
</pre>
To use https you need to start tupi with -certfile
and -keyfile
flags.
$ tupi -root myfiles -certfile /my/file.pem -keyfile /my/file.key
You can use a config file instead of command line options. Check the documentation here.
Tupi also supports the use of virutal domains. Check the virtual domains documantation here.
Tupi can be exteded by plugins. Check the documentation on how to write plugins for tupi
Check the full documentation here.