Revision 4 as of 2009-02-24 13:12:03

Clear message

Hello world V2

http://localhost:8000/hello/moon/ napísalo Hello, moon.

   1     (r'^hello/(.*)/$', views.hello),

views.py bude takéto:

   1 from django.http import HttpResponse
   2 
   3 def hello(request,who):
   4     html="""<html>
   5     <body>
   6     <h1>Hello, """+who+"""</h1>
   7     </body>
   8     </html>
   9     """
  10     return(HttpResponse(html))
views.py

Úlohy

  1. Skúste http://localhost:8000/hello/moon/sun . Prerobte to tak, aby funkcia {view.hello vypísala iba Hello, moon.

  2. A teraz tak, aby vypísala Hello, moon and sun.

  3. A teraz chceme, aby to fungovalo všeobecne, t.j. napríklad http://localhost:8000/hello/a/b/c/ má vypísať Hello, a,b and c