Total Pageviews

Monday, 4 July 2022

一个基于c语言的tiny-web-server


a tiny web server in C.

I am reading Computer Systems: A Programmer's Perspective. It teaches 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.

Features

  1. Basic MIME mapping
  2. Very basic directory listing
  3. Low resource usage
  4. sendfile(2)
  5. Support Accept-Ranges: bytes (for in browser MP4 playing)
  6. Concurrency by pre-fork

Non-features

  1. No security check

Usage

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.

from https://github.com/shenfeng/tiny-web-server

-----

在linux vps上。

git clone https://github.com/shenfeng/tiny-web-server

cd tiny-web-server

make

(在当前目录下,就会生成可执行文件tiny)
./tiny 2345

在你本地机器的浏览器上,访问vps-public-ip:2345

No comments:

Post a Comment