Skip to content
/ tinyhttp Public

Performant static file HTTP server using Nim for speed.

License

Notifications You must be signed in to change notification settings

Pebaz/tinyhttp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

tinyhttp

Performant static file HTTP server using Nim for speed.

Features

  • High performance
  • Extremely lightweight (~1MB once compiled)
  • Render Markdown as HTML (MarkDeep)

Description

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.

Installation

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

Usage

You can use tinyhttp in 3 different ways:

  • As a library, for an ultra-lightweight HTTP server
  • As a runnable module
  • From the CLI

Library

import time
from tinyhttp import HttpServer

server = HttpServer(log=True)
server.start()
time.sleep(10)  # Do other things while serving in background
server.stop()

Runnable Module

$ python3 -m tinyhttp --host "0.0.0.0" --port 9090 --dir ../../

CLI

$ tinyhttp --host "0.0.0.0" --port 9090 --dir ../../