Skip to main content
Warning: You are using the test version of PyPI. This is a pre-production deployment of Warehouse. Changes made here affect the production instance of TestPyPI (
Help us improve Python packaging - Donate today!

Super basic HTTP server for creating and testing REST APIs

Project Description

HTTP server in a single Python file. Offers a Python decorator to register functions for URL resources using regular expressions we all know and love.* Handy for trying out your future REST api ideas.

  • Written in a single .py file
  • No extra libraries needed
  • Uses Python logging module
  • Self documenting API index at / when you use docstrings on the handlers.
  • /yahs/reload reloads any module(s) that register any handlers to save stopping/starting server
  • Basic Cross-Origin Resource Sharing (CORS) responses enabled for all request types

Probably not better than Django, Flask, Jersey or other framework :P


Using pip

pip install yahs

Manual Install

python install

Sample Usage

from yahs import Server, Response
@Server.handle('GET', '^/food$')
def get_food(request):
    return "Hello there, here's some food!"

@Server.handle('GET', r'/products/(?P<product_id>[0-9]+)')
def get_product_by_id(request, product_id):
    """Gets a product by numeric id.
    E.g /products/240
    The regex named group/backreference 'product_id' will get added to the call when
    someone requests the matching url pattern. It will have the value 240.
    response = Response()
    response.body = "<h1>Yo here it is... Product: #{}</h1>".format(product_id)
    return response

server = Server()  # default port is 4321
server.wait()  # blocks the program from exiting early for short lived programs


MIT License


  • Support class based Resource decorators with get, post, delete etc methods.

**Results may vary depending on how much you know and love regular expressions.*

Release History

This version
History Node


History Node


Download Files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

File Name & Hash SHA256 Hash Help Version File Type Upload Date
(7.8 kB) Copy SHA256 Hash SHA256
Source Jun 17, 2015

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting