In the use of building a public platform, the use of web.py this convenient and simple framework, learning.
Framework Document:http://webpy.org/docs/0.3/tutorial.zh-cn write to the contents of the document once you get started, there's no problem.
To Run the program: CMD--Enter the path to the file--Enter a python file name to run
Problems encountered:
1. In the template file, the first line must start with the $def with (), or an error will be
$def with (name) $if name: I just wanted to say <em>hello</em> to $name. $else: <em>hello</em , world!
2. The Python statement in the template file HTML cannot be commented on, otherwise it will be an error. Others can be commented
Question 3: page jumps and redirects--web.seeother and Web.redirect
Links: http://doc.outofmemory.cn/python/webpy-cookbook/redirect-seeother.html
Class add: def POST (self): i=web.input () n=db.insert (' Todo ', title=i.title) raise Web.seeother ('/') )
After the Post method receives a post and finishes processing, it sends a 303 message and a new URL to the browser. Next
The browser makes a GET request for the new URL, which completes the new jump.
Note: Web.seeother and Web.redirect do not support versions below 0.3.
Difference:
It seems to be possible to do the same thing with the Web.redirect method, but usually it is too friendly. Because Web.redirect is sending 301 messages-
This is a permanent redirect. Because most Web browsers cache new redirects, when we do that again, we automatically access
redirect The new URL. Many times, this is not the result we want. So when submitting the form, try to use Seeother. But in the following to
In this case, it is most appropriate to use redirect: We have changed the URL structure of the site, but still want to let the user bookmarks/favorites
The old URL does not expire. (Note: To understand the difference between seeother and redirect, it is best to look at the meanings of different message codes in the HTTP protocol.) )
Get started with a little python:web.py frame every day