2

When using web.py framework. you can redirect an url to a subapplication. e.g (code.py):

import web
import subapp1

urls = (
    "/sub1", subapp1.app,
    "/(.*)", "index"
)
....

this is really straight forward.

However, when writing subapp1.py which has its own url handlers, if i want to re-route some url, say '/sub2', to another subapplication (subapp2), i am failing.

Formerly in subapp1.py

import web
import subapp2

urls = (
    "/sub2", subapp2.app,
    "/(.*)", "some_local_class"
)
....

GET request to "/sub1/sub2/", is handled by "some_local_class" in supapp1.py. But i need this url is re-routed to subapp2.py.

Is there anything i am missing? Or may be this is not recommended url handling methodology in web.py?

1 Answer 1

1

After some trial-error, found that there is nothing wrong with web.py and rerouting from subapp to another subapp. It is all working perfectly.

What is wrong is my method. Do not try to create a subapp in package's init.py file. At least when i moved subapp to its own module, it all worked well.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.