Conteúdo do Curso
Django: Build Your First Website
Django: Build Your First Website
URLs
URL (Uniform Resource Locator) is an address that points to the location of a resource on the internet, such as a web page, image, video, or other file. A URL consists of several parts:
- Protocol: This is the initial part of the URL that indicates the type of protocol used to access the resource. The most common protocol is HTTP (HyperText Transfer Protocol) or HTTPS (HTTP Secure), but others;
- The
your-server.com/
is an address to the server; - Everything following, for example,
storage/list
, constitutes parts of the URL address, representing specific pages on a given website. This portion of the URL triggers corresponding functionality on the server-side of the application to send the necessary data for that page.
This distribution allows for clear site navigation and logical separation of server functionality for future updates.
URLs and Views
When a user navigates to a URL in Django, Django compares the URL to the URLs that have been defined in the urls.py
file. If the URL matches one of the URLs defined in the urls.py
file, Django triggers the function that is responsible for handling that URL.
Functions that are responsible for handling URLs are called views. Views can be defined in the views.py
file.
Obrigado pelo seu feedback!