git clone https://github.com/liangguohuan/tiny-web-server.git
sudo make installsudo make uninstalltinyserver [dir] [port] ...
- auto add slash and send status 301 if request is dir
- auto index file index.html
- use dataTables to show files friendly if request is dir
- more commands in Makefile
check
check compile errorinstall
commandtinyserverwill be installed in/usr/local/binuninstall
remove commandtinyserverand config files
- cache dir list if exec overtime 3 seconds
- open file with xdg-open and send status 403 if mime type not support
- 2017-06-30 the standard codes for clang
- 2017-06-29 limit for parsing request header when loop rio_readinitb()
- 2017-06-29 fixed strange thing return empty call rio_readlineb()
- 2017-06-28 perfect tiny.c and add new feature cache dir list
- 2017-06-28 replace c99 into c11 and more commands in Makefile
- 2017-06-27 use dataTables to show nicely in handle_directory_request
- 2017-06-27 video mime type not support call system program
- 2017-06-25 Disabled warning: implicit-function-declaration
- 2017-06-25 fixed mp4 stream range request
- 2017-06-25 auto add slash if request is dir
- 2017-06-25 add auto index file feture
I am reading Computer Systems: A Programmer's Perspective. It teachers me how to write a tiny web server in C.
I have written another tiny web server in JAVA.
And another one http-kit, http-kit is full featured, with websocket and async support
And few others on my github page.
- Basic MIME mapping
- Very basic directory listing
- Low resource usage
- sendfile(2)
- Support Accept-Ranges: bytes (for in browser MP4 playing)
- Concurrency by pre-fork
- No security check
tiny <port>, opens a server in the current directory, port
default to 9999, just like python -m SimpleHTTPServer
I use it as a lightweight File Browser.
- Write a epoll version
The code is free to use under the terms of the MIT license.