Forums

Deploying circuits.web applications

I am trying to deploy a circuits.web application (http://circuitsframework.com) with the following code being placed into my user_pythonanywhere_com_wsgi.py file:

from circuits.web import Controller
from circuits.web.wsgi import Application

class Root(Controller):
    def index(self):
        return "Hello World!"

application = Application()
Root().register(application)

However I get an ERR_CONTENT_LENGTH_MISMATCH error when I try to access the page.

When I follow the instructions on https://help.pythonanywhere.com/pages/UsingCherryPy/ I get a Hello World message. CherryPy is similar to circuits.web in some ways but I am not sure what I am doing wrong. Any suggestions?

[edit by admin: formatting]

I'm not familiar with the Circuits framework, but from this blog post I get the impression that this might work:

from circuits.web import Controller
from circuits.web.wsgi import Application

class Root(Controller):
    def index(self):
        return "Hello World!"

application = Application() + Root()

Yeah I have tried that as well with no luck. I am stuck on this not sure why it would not work it is throwing a TypeError.

2018-12-13 16:02:44,631: Error running WSGI application
2018-12-13 16:02:44,636: TypeError: 'Root' object is not callable
2018-12-13 16:02:53,574: Error running WSGI application
2018-12-13 16:02:53,574: TypeError: 'Root' object is not callable
2018-12-13 16:02:53,877: Error running WSGI application
2018-12-13 16:02:53,878: TypeError: 'Root' object is not callable
2018-12-13 16:02:56,254: Error running WSGI application
2018-12-13 16:02:56,255: TypeError: 'Root' object is not callable
2018-12-13 16:02:56,536: Error running WSGI application
2018-12-13 16:02:56,537: TypeError: 'Root' object is not callable
2018-12-13 16:03:26,747: Error running WSGI application
2018-12-13 16:03:26,747: TypeError: 'Root' object is not callable

Any reason as to why this would be?

Can I take a look at your files? We can see it from our admin interface, but we always ask for permission first.

Yeah please do! Just playing around trying to figure everything out, nothing sensitive on there. Thanks for your help!

Thanks! So right now you have

application = Root() + Application()

Could you see if

application = Application() + Root()

...works? It might be that addition of these objects isn't commutative.

So I tried

application = Application() + Root()

... and it didn't change anything. I don't think WSGI support for circuits is very good, if I can't get this working I'll have to switch to CherryPy or Flask.

When I navigate to enter link description here my browser gives me the following:

patx.pythonanywhere.com unexpectedly closed the connection.
ERR_CONTENT_LENGTH_MISMATCH

And the app is still throwing a TypeError saying my Root() Controller class isn't callable, which I'm not really understanding.

Switching to Python 2.7 has seemed to solve the issue, I am now seeing Hello World when I navigate to my app's URL. Thanks for all your help.

Ahah! I never would have thought of that. It's odd, though -- Circuits claim to support 3.4, 3.5 and 3.6 in on their page. Were you using 3.7 previously? If so, it might be interesting to try out 3.6.

Fixed most the errors I was having: github.com/circuits/circuits/pull/257

Awesome -- thanks!