Help with tutorial after getting an Internal server error

88 views
Skip to first unread message

Barry Anderson

unread,
Dec 15, 2011, 12:58:55 AM12/15/11
to we...@googlegroups.com
Hi

I'm working through a webpy tutorial [1] and I've run into a problem.
All the code samples in the tutorial work fine for me but when I add
the next two pieces of code my browser gives me an internal server
error:
--------------------
class hello:
def GET(self):
return render.hello("Templates demo", "Hello", "A long time ago...")

class bye:
def GET(self):
return render.bye("Templates demo", "Bye", "14", "8", "25", "42", "19")
--------------------
Here's the code of my hello.py file:
--------------------
import web

urls = (
'/', 'hello',
'/bye/', 'bye')


application = web.application(urls, globals()).wsgifunc()

render = web.template.render('templates/')

class hello:
def GET(self):
return render.hello("Templates demo", "Hello", "A long time ago...")

class bye:
def GET(self):
return render.bye("Templates demo", "Bye", "14", "8", "25", "42", "19")


if __name__ == "__main__":
app.run()
--------------------

I'm using WSGI on windows.

Any help would be appreciated.

[1] http://webpy.org/tutorial3

Anand Chitipothu

unread,
Dec 15, 2011, 3:28:40 AM12/15/11
to we...@googlegroups.com
2011/12/15 Barry Anderson <bare...@googlemail.com>:

I guess you should be calling application.run(). Thats what you've
defined on the top.

Anand

Barry

unread,
Dec 15, 2011, 4:47:54 AM12/15/11
to we...@googlegroups.com
Hi Anand.

Yeah, I've added application.run() but still the same result.

Anand Chitipothu

unread,
Dec 15, 2011, 4:51:52 AM12/15/11
to we...@googlegroups.com
2011/12/15 Barry <bare...@googlemail.com>:

> Hi Anand.
>
> Yeah, I've added application.run() but still the same result.

Try this:

app = web.application(urls, globals())
application = app.wsgifunc()

if __name__ == "__main__":
app.run()

web.py application object has run method. You are trying to call run
on wsgi function.

Anand

Barry

unread,
Dec 15, 2011, 5:16:58 AM12/15/11
to we...@googlegroups.com
I tried that but still same result. Here's what I've got now:


import web

urls = (
  '/', 'hello',
  '/bye/', 'bye')


render = web.template.render('templates/')

class hello:
    def GET(self):
        return render.hello("Templates demo", "Hello", "A long time ago...")

class bye:
    def GET(self):
        return render.bye("Templates demo", "Bye", "14", "8", "25", "42", "19")


               

Anand Chitipothu

unread,
Dec 15, 2011, 6:00:10 AM12/15/11
to we...@googlegroups.com
2011/12/15 Barry <bare...@googlemail.com>:
> I tried that but still same result. Here's what I've got now: [...]

It seems to be working for me. What is the error that you are getting.

Anand

Barry

unread,
Dec 15, 2011, 6:22:12 AM12/15/11
to we...@googlegroups.com
I'm using Firefox and it just comes up with "internal server error". There's no other error info. Do you think it's a problem with WSGI, or the way I've got Apache configured?

Primoz Anzur

unread,
Dec 15, 2011, 6:33:35 AM12/15/11
to we...@googlegroups.com
Why don't you have a debug enabled, if it's for local development?

You can add this line to the script: 

web.config.debug = True

Or, alternatively, check the apache error logs, or, last but not least use web.py's internal web server to see the error.


On Thu, Dec 15, 2011 at 12:22 PM, Barry <bare...@googlemail.com> wrote:
I'm using Firefox and it just comes up with "internal server error". There's no other error info. Do you think it's a problem with WSGI, or the way I've got Apache configured?

--
You received this message because you are subscribed to the Google Groups "web.py" group.
To view this discussion on the web visit https://groups.google.com/d/msg/webpy/-/VxqbYnJRCLMJ.

To post to this group, send email to we...@googlegroups.com.
To unsubscribe from this group, send email to webpy+un...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/webpy?hl=en.

Barry

unread,
Dec 15, 2011, 7:09:34 AM12/15/11
to we...@googlegroups.com
It's just coming up with this error: "No template named hello".
I've checked and there is definitely a hello.html file, and the path is correct.
Reply all
Reply to author
Forward
0 new messages