Alex,
Works great. But I need a link from the first page to load another
page. Here is my code
----------------------------------------------
from twisted.web.server import Site
from twisted.web.resource import Resource
from twisted.internet import reactor
from twisted.web.static import File
class PaymentRequired(Resource):
def render_GET(self, request):
request.setResponseCode(402)
return "<html><body>Please swipe your credit card.</body></html>"
class menu(Resource):
def render_GET(self, request):
request.setResponseCode(402)
return "<html><body><a href=http://192.168.1.101:3333/buy/
>Integrater</a></body></html>"
root = Resource()
root.putChild("foo", File("/tmp"))
root.putChild("bar", File("/lost+found"))
root.putChild("baz", File("/opt"))
root.putChild("varr", File("/var"))
root.putChild("buy", PaymentRequired())
root.putChild("men", menu())
factory = Site(root)
reactor.listenTCP(3333, factory)
reactor.run()
----------------------------------------------
It will not load the second page.
On Sep 29, 8:55 pm, William Stein <[email protected]> wrote:
> On Tue, Sep 29, 2009 at 5:12 PM, Alex Clemesha <[email protected]> wrote:
>
> > On Tue, Sep 29, 2009 at 4:42 PM, William Stein <[email protected]> wrote:
>
> >> On Tue, Sep 29, 2009 at 4:41 PM, Alex Clemesha <[email protected]> wrote:
>
> >>> On Tue, Sep 29, 2009 at 8:26 AM, Mikie <[email protected]> wrote:
>
> >>>> Does anyone have an example of a twisted server that loads 2 html
> >>>> pages from a url?
> >>>> --www.twisted.com:8000/page1/,www.twisted.com:8000/page2/
> >>>> Same port.
> >>> Here are some very nice Twisted web tutorials:
> >>>http://jcalderone.livejournal.com/tag/sixty+seconds
>
> >>> You'll be able to figure out you above question, and more,
> >>> pretty easily from them. Send another email if you're still having
> >>> trouble after checking those out.
>
> >>> -Alex
>
> >> Alex, how hard is it to migrate from "Twisted.web2" which is used in
> >> Sage back to "Twisted.web"?
> > Pretty easily actually... the Resource object is pretty similar, the
> > main difference is that the Web2 Resource object has the "locateChild"
> > method,
> > where as the Web Resource has "getChild" - and even those are pretty
> > similar.
>
> > Also, there's some subtle differences in the way you doing
> > "rendering"... i.e. with Web2 you subclass Resource/PostableResource and
> > then
> > you use the "render" method, where are with Web you just subclass Resource
> > and implemented either "render_GET" or "render_POST".
>
> > Probably just looking through the examples here:
> >http://jcalderone.livejournal.com/tag/sixty+seconds
> > would be good enough to do the switch.
>
> > The Web code is being actively maintained and improved... One
> > major improvement that will being going into Twisted 9.0 (due tomorrow on
> > the Twisted trac actually), is the nice WSGI support (for running
> > Django, etc).
> > In Codenode we use the trunk Web code, but in just a couple of days we
> > will be able to remove all that code, and very cleanly run Django off a
> > standard install of Twisted, which is extremely convenient.
>
> Thanks. That was incredibly helpful and greatly appreciated.
>
> William- Hide quoted text -
>
> - Show quoted text -
--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org
-~----------~----~----~----~------~----~------~--~---