/http-server

Simple http server written in C

Primary LanguageCMozilla Public License 2.0MPL-2.0

http-server

[Work in progress]

Simple HTTP server that serves files from a directory. It is written in C using the libmicrohttpd library.

Compiling:

  1. Install dependencies
    • libmicrohttpd (arch: libmicrohttpd, debian: libmicrohttpd-dev)
    • cJSON (arch: cjson, debian: libcjson-dev)
    • libmagic (arch: file, debian: libmagic-dev)
    • sudo pacman -S libmicrohttpd cjson file
      
    • sudo apt install libmicrohttpd-dev libcjson-dev libmagic-dev
      
  2. Run meson setup build
  3. Run meson compile -C build
  4. Binary will be created at build/http-server

The server supports directory listing and file preview.

Preview:

Directory Listing

Directory Listing

Text Preview

Text Preview

Working on:

  • Read files from disk to serve
    • File caching
      • Cache invalidation
      • MIME type detection
      • Large file support (don't cache?)
  • Directory listing
  • File preview
    • Text
      • Convert non-UTF8 text to UTF8
      • Line numbers
      • Syntax highlighting
    • Images
    • Audio
    • Video

Planned features:

  • Code cleanup
  • Documentation
  • Finer control over the server
    • Cache control
    • Custom index page
    • Custom error pages
    • Set specific MIME types which are served as raw data (without file preview)
  • Signal to drop cache