Render "Hi"
In this chapter, we will be working with two files, urls.py and views.py.
-
In
views.py, we will write a function that will display a page in the browser with the message "Hello, world!"; -
In the
urls.pyfile, we will create a URL address for our page.
We have the implemented hi view in views.py file.
from django.http import HttpResponse
from django.shortcuts import render
# Create your views here.
def hi(request):
return HttpResponse("<h1>Hi</h1>")
Import this view to the urls.py and add path to urlpatterns.
from django.urls import path
from .views import hi
urlpatterns = [
path('', hi)
]
Video Explanation
Merci pour vos commentaires !
Demandez à l'IA
Demandez à l'IA
Posez n'importe quelle question ou essayez l'une des questions suggérées pour commencer notre discussion
Awesome!
Completion rate improved to 4
Render "Hi"
Glissez pour afficher le menu
In this chapter, we will be working with two files, urls.py and views.py.
-
In
views.py, we will write a function that will display a page in the browser with the message "Hello, world!"; -
In the
urls.pyfile, we will create a URL address for our page.
We have the implemented hi view in views.py file.
from django.http import HttpResponse
from django.shortcuts import render
# Create your views here.
def hi(request):
return HttpResponse("<h1>Hi</h1>")
Import this view to the urls.py and add path to urlpatterns.
from django.urls import path
from .views import hi
urlpatterns = [
path('', hi)
]
Video Explanation
Merci pour vos commentaires !