Getting StartedΒΆ

Just like any application or system built with circuits, a circuits.web application follows the standard Component based design and structure whereby functionality is encapsulated in components. circuits.web itself is designed and built in this fashion. For example a circuits.web Server’s structure looks like this:


To illustrate the basic steps, we will demonstrate developing your classical “Hello World!” applications in a web-based way with circuits.web

To get started, we first import the necessary components:

from circutis.web import Server, Controller

Next we define our first Controller with a single Request Handler defined as our index. We simply return “Hello World!” as the response for our Request Handler.

class Root(Controller):

   def index(self):
      return "Hello World!"

This completes our simple web application which will respond with “Hello World!” when anyone accesses it.

Admittedly this is a stupidly simple web application! But circuits.web is very powerful and plays nice with other tools.

Now we need to run the application:

(Server(8000) + Root()).run()

That’s it! Navigate to: and see the result.

Here’s the complete code:

from circuits.web import Server, Controller

class Root(Controller):

   def index(self):
      return "Hello World!"

(Server(8000) + Root()).run()

Have fun!