Serve a Page from Server - Function view
Specification
Responds to requests to the url `/sample-page` with a simple string response.
Prerequisites
* You need to have a django project called `django_sample` set up, as shown here: [Writing your first Django app, part 1: Creating a project - djangoproject.com](https://docs.djangoproject.com/en/4.0/intro/tutorial01/#creating-a-project)
* You need to have a django app `example` set up, as shown here: [Writing your first Django app, part 1: Creating the Polls app - djangoproject.com](https://docs.djangoproject.com/en/4.0/intro/tutorial01/#creating-the-polls-app)
Code
`example\urls.py`
```python
from django.urls import path
import example.views as views
urlpatterns = [
...
path('sample-page', views.view_sample_page, name='sample_page'),
]
```
`example\views.py`
```python
from django.http import HttpResponse
def view_sample_page(request):
return HttpResponse("Welcome to the sample page!")
```
`django_sample\urls.py`
```python
from django.urls import include, path
urlpatterns = [
...
path('', include('example.urls')),
]
```
Further reading
### Guides/Articles
[Writing your first Django app, part 1 - djangoproject.com](https://docs.djangoproject.com/en/4.0/intro/tutorial01/#write-your-first-view)
References
{
"classes":
[
{
"name" : "django.http.HttpResponse",
"urls" : ["https://docs.djangoproject.com/en/4.0/ref/request-response/#httpresponse-objects"]
}
],
"functions":
[
{
"name" : "django.urls.include",
"urls" : ["https://docs.djangoproject.com/en/4.0/ref/urls/#include"]
},
{
"name" : "django.urls.path",
"urls" : ["https://docs.djangoproject.com/en/4.0/ref/urls/#path"]
}
]
}
Problem Description
In your server back-end software, create a new accessible page (e.g. in `/sample-page`) that outputs something simple