Reputation: 1405
I have to import another class in webpy Web.py
urls = (
'/', "Home"
)
class Web:
def __init__(self):
app = web.application(urls, globals())
app.run()
home.py
class Home:
def GET(self):
return "Hello, world!"
can any one tell me why this is not working?
Upvotes: 1
Views: 652
Reputation: 175
To import from other paths just add at start of entrypoint:
sys.path.insert(0, './$srcdir')
And select class from module:
...
routes = ('/', 'controllers.IndexController')
....
Upvotes: 0
Reputation: 4479
If both files are in the same folder then you may try this:
urls = (
'/', "home.Home"
)
Upvotes: 2
Reputation: 29913
Adding
import web
from home import Home
to your main module should do the trick for the import.
Then, your web app is not started until you instantiate your Web
class. Why don't you just follow the tutorial code and say
if __name__ == "__main__":
app = web.application(urls, globals())
app.run()
instead?
Upvotes: 1