Performant static file HTTP server using Nim for speed.
- High performance
- Extremely lightweight (~1MB once compiled)
- Render Markdown as HTML (MarkDeep)
tinyhttp gets its speed from Nim. Nim is a powerful language with the speed of C and the expressiveness of Python. Fabio Cevasco created a tiny HTTP server in Nim called nimhttpd. Make sure to head over to his repository and star it 🙂. Nimporter (a library that allows you to directly-import Nim files), made the porting process almost effortless.
In order to run tinyhttp, you must install:
- The Nim programming language
- Nimpy (
nimble install nimpy
) - Nimporter (
pip install nimporter
)
$ pip install git+https://github.com/Pebaz/tinyhttp
You can use tinyhttp in 3 different ways:
- As a library, for an ultra-lightweight HTTP server
- As a runnable module
- From the CLI
import time
from tinyhttp import HttpServer
server = HttpServer(log=True)
server.start()
time.sleep(10) # Do other things while serving in background
server.stop()
$ python3 -m tinyhttp --host "0.0.0.0" --port 9090 --dir ../../
$ tinyhttp --host "0.0.0.0" --port 9090 --dir ../../