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.py
file, we will create a URL address for our page.
We have the implemented hi
view in views.py
file.
python9123456from django.http import HttpResponsefrom 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
.
python9123456from django.urls import pathfrom .views import hiurlpatterns = [path('', hi)]
Video Explanation
Video Player is loading.
Loaded: 0%
Current Time 0:00
/
Duration -:-
- , opens subtitles settings dialogsubtitles settings
- , selectedsubtitles off
1x
- 2x
- 1.5x
- , selected1x
- 0.5x
This is a modal window.
The media could not be loaded, either because the server or network failed or because the format is not supported.
Beginning of dialog window. Escape will cancel and close the window.
End of dialog window.
¿Todo estuvo claro?
¡Gracias por tus comentarios!
Sección 2. Capítulo 4
Pregunte a AI
Pregunte a AI
Pregunte lo que quiera o pruebe una de las preguntas sugeridas para comenzar nuestra charla