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.
War alles klar?
Danke für Ihr Feedback!
Abschnitt 2. Kapitel 4
Fragen Sie AI
Fragen Sie AI
Fragen Sie alles oder probieren Sie eine der vorgeschlagenen Fragen, um unser Gespräch zu beginnen