A Hello World App

Writing the Hello World app

Free preview

New files

app/urls.py
from django.urls import path
from app.views import home

urlpatterns = [
    path("", home),
]

Modified files

app/views.py
--- 
+++ 
@@ -1,3 +1,4 @@
-from django.shortcuts import render
+from django.http import HttpResponse

-# Create your views here.
+def home(request):
+    return HttpResponse("Hello, World!")
djangocourse/settings.py
--- 
+++ 
@@ -31,6 +31,7 @@
 # Application definition

 INSTALLED_APPS = [
+    "app.apps.AppConfig",
     'django.contrib.admin',
     'django.contrib.auth',
     'django.contrib.contenttypes',
djangocourse/urls.py
--- 
+++ 
@@ -15,8 +15,9 @@
     2. Add a URL to urlpatterns:  path('blog/', include('blog.urls'))
 """
 from django.contrib import admin
-from django.urls import path
+from django.urls import path, include

 urlpatterns = [
     path("admin/", admin.site.urls),
+    path("", include("app.urls"))
 ]