Search code examples
python-2.7serverweb.py

After installing lpthw.web the does nothing


So, I am going over "Learn Python The Hard Way" and have an issue with Chapter 50 "Building my first website".

jharvard@appliance (~/Dropbox/Python/gothonweb): ls -R
bin  docs  gothonweb  templates  tests

./bin:
app.py

./docs:

./gothonweb:
__init__.py

./templates:

./tests:
__init__.py

Trying to run app.py file with command: $python bin/app.py It supposed to start the server but it does not do anything at all. It just return to a prompt again.

#app.py 
import web

urls = (
    '/', 'index'
)

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

class index:
    def GET(self):
        greeting = "Hello world"
        return greeting

if __name__ == "__main__":
    app.run

I installed lpthw using pip first.

$pip install lpthw.web

When I run the file it gave me ImportError: no 'web' exists So I installed webpy myself using with help of http://webpy.org/install And now I'm getting no result at all. Python I am using is Python 2.7.8 : Anaconda 2.1.0 . So there must be no conflict. Any suggestions? Thank you.


Solution

  • So, I fixed it successfully but adding parenthesis to the function app.ru()

    #app.py 
    ....
            greeting = "Hello world"
            return greeting
    
    if __name__ == "__main__":
        app.run