hello world program in django

just updating the sample project ...... with hello message


ie.,


http://letusknowdjango.blogspot.in/2014/09/sample-project-in-django.html


view.py
=====
from django.http import HttpResponse
import datetime

def hello(request):
  return HttpResponse("Hello world")
def current_datetime(request):
   now = datetime.datetime.now()
   html = "<html><body>It is now %s.</body></html>" % now
   return HttpResponse(html)





similarly.....


urls.py
====
from django.conf.urls import patterns, include, url
from django.contrib import admin
from mysite.view import current_datetime
from mysite.view import hellourlpatterns = patterns('',
 url(r'^hello/$', hello),
 url(r'^time/$', current_datetime),
)





Note:
here i added the red color code for update the program.... in the project with hello message


and out put for hello is




No comments:

Post a Comment