Skip to content

spaceone/circuits.http

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

circuits.http

circuits.http is a asynchronous framework for building web and HTTP related applications such as HTTP servers, clients, proxies and caches. It is based on two libraries which allows very powerful and flexible API design:

  • circuits which provides the asynchronous event system as well as socket handling
  • httoop as interface for handling of HTTP messages

The design of circuits.http is developped to build web applications in the REST architectural style.

Features of the HTTP Server

Features of the HTTP Client

  • Following redirections
  • Sessions via Cookies with ability to define own Cookie-Policies

Planned Features

Examples

A simple HTTP server example with one resource which returns a plaintext document with the content "Hello World!" can be started with the following code:

Start a example server:

python examples/server/hello_world.py --bind http://0.0.0.0:8090/ --no-daemon

Request the resource either with firefox or with curl.

curl -i 'http://localhost:8090/'
firefox 'http://localhost:8090/'
from circuits.http.server.__main__ import HTTPServer
from circuits.http.server.resource import Resource, method, Domain


class HelloWorld(Resource):

	path = '/'

	@method
	def GET(self, client):
		return 'Hello World!'
	GET.codec('text/plain')


class Server(HTTPServer):

	logformat = '%(h)s %(l)s %(u)s %(t)s %(s)s "%(r)s" "%(H)s" %(b)s "%(f)s" "%(a)s"'

	def add_components(self):
		super(Server, self).add_components()
		root = Domain('localhost')
		root += HelloWorld(channel='hello-world')
		self.domains += root


Server.main()

More examples:

Status

Build Status

codecov