# | Likes | Tech tags | Title | Creator | Created date |
---|---|---|---|---|---|
1 | 0 |
Django
|
2022-06-13 23:34
|
Responds to requests to the url /sample-page
with a simple string response.
django_sample
set up, as shown here: Writing your first Django app, part 1: Creating a project - djangoproject.comexample
set up, as shown here: Writing your first Django app, part 1: Creating the Polls app - djangoproject.comexample\urls.py
from django.urls import path
import example.views as views
urlpatterns = [
...
path('sample-page', views.view_sample_page, name='sample_page'),
]
example\views.py
from django.http import HttpResponse
def view_sample_page(request):
return HttpResponse("Welcome to the sample page!")
django_sample\urls.py
from django.urls import include, path
urlpatterns = [
...
path('', include('example.urls')),
]
classes | |
django.http.HttpResponse |
docs.djangoproject.com |
functions | |
django.urls.include |
docs.djangoproject.com |
django.urls.path |
docs.djangoproject.com |
In your server back-end software, create a new accessible page (e.g. in /sample-page
) that outputs something simple