8. Building a lightweight project

The components of Django that we’ve just looked at are really just Python packages that we can import into whichever file structure we wish to create.

The tutor showed us how to create a lightweight site. The idea of this is to replace the helloworld functionality we’ve seen in the last few exercises.

We create a folder called lightweight_site and in it, a file called helloworld.py.

from django.http import HttpResponse
from django.conf.urls import url
from django.urls import path
from django.conf import settings
import sys
def index(request):
    return HttpResponse('<html><head></head><body><p>Hello world!</p></body></html>')
urlpatterns = [
    path('', index)
if __name__ == "__main__":
    from django.core.management import execute_from_command_line


Wednesday 20 October 2021, 59 views

Leave a Reply

Your email address will not be published.