I installed the web framework thus
pip install lpthw.web
Then I created a project for the web application by creating a directory in my projects directory:
ex50
/bin
app.py
/docs
/gothonweb
__init__.py
/templates
__init__.py
/tests
I just copied the code provided in LPTHW in app.py
I ran the webserver with 'python bin/app.py' and successfully loaded the url http://localhost:8080
However, I realized that lpthw.web was not installed in my virtualenv as I would have expected it to be. It was actually installed in /usr/local/lib/python2.6/dist-packages/ This seems strange and incorrect to me. I am not quite sure what went wrong, so I asked a question on StackOverflow.
The code for this exercise is embedded below:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import web | |
urls = ( | |
'/', 'index' | |
) | |
app = web.application(urls, globals()) | |
render = web.template.render('templates') | |
class index: | |
def GET(self): | |
greeting = "Hello" | |
return render.index(greeting = greeting) | |
if __name__ == "__main__": | |
app.run() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$def with (greeting) | |
<html> | |
<head> | |
<title>Gothons Of Planet Percal #25</title> | |
</head> | |
<body> | |
$if greeting: | |
I just wanted to say <em style="color: green; font-size: 2em;">$greeting</em>. | |
$else: | |
<em>Hello</em>, world! | |
</body> | |
</html> |
Hi what is the password of lpthw.web
ReplyDeleteit keeps telling me try again