theory Flashcards
responsibilities of backend programmers could easily involve
writing APIs,
writing code to interact with a database,
creating modules or libraries,
working on business data and architecture
Coordinate and communicate with frontend developers to transfer data efficiently to the client side of the application.
Collaborate with quality assurance engineers to optimize the server-side processes and pass some security checks.
Optimize the application when the number of requests or users scales as well.
Analyze the requirements of the project and create a simple structure to handle bugs and errors.
Propose efficient solutions for cloud hosting but also build CI/CD pipelines.
what is an API?
It consists mainly of two components:
The technical specification, which describes the data exchange options between the parties, with the specification made in the form of a request for data delivery protocols and data processing.
The software interface (the programming code), which is written to the specification that represents it.
Web APIs are relatively common and there are different specifications and protocols.
Remote Procedure Call (RPC)
Simple Object Access Protocol (SOAP)
REST/RESTful
The REST architecture uses the original specifications of the HTTP protocol
Rule 1: The URL is a resource identifier
Rule 2: HTTP verbs are identifiers of operations
Rule 3: HTTP responses are representations of resources
Rule 4: Links are relations between resources
Rule 5: A parameter is an authentication token
HTTP Requests
https://www.educative.io/courses/full-stack-django-and-react/what-is-an-api#Understanding-REST-APIs
https://miro.medium.com/v2/resize:fit:960/1*iDq9WkZDedlMW_1bCtZo_w.png
Why use Django?
It provides code and tools for common operations such as database manipulation, HTML templates, URL routing, session management, and security.
Django allows developers to build all kinds of web applications (social networks, news sites, and wikis) with all the necessary basics
Django provides protection against common attacks—cross-site scripting, SQL injection, and much more.
Django REST Framework (DRF)
It’s the most mature, testable, well-documented, and easily extendable framework, which will help create powerful RESTful APIs when coupled with Django.
The combination of Django and the DRF is used by large companies such as Instagram, Mozilla, and even Pinterest.
Setting Up the Work Environment
https://www.educative.io/courses/full-stack-django-and-react/setting-up-the-work-environment
Migrations are
just a way to propagate changes made to the model in the database schema.
When we write our own models, we’ll also be creating migrations files and migrating them.
No need to write SQL commands here—we’ll just write code in Python that will be directly translated into SQL. The command python manage.py migrate will then apply these changes to the database.
Django has object-relational mapping (ORM) that
automatically handles the interaction with the database for us.
When we create a model in our Django application, the framework will automatically create a suitable table in the database that will save the data relating to the model.
Project components
settings.py: This contains all the configurations for your Django projects. You can find SECRET_KEY, the INSTALLED_APPS list, ALLOWED_HOST, and so on.
manage.py: It’ll help us create projects and applications, run migrations, start a server, and so on.
urls.py: This contains all the URLs that will be used to access resources in the project:
???
wsgi.py: This file is basically used for deployment but also as the default development environment in Django.
asgi.py: Django also supports running asynchronous codes as an ASGI application.
sqlite3 as a database,
which is an in-process library that implements a
fast
self-contained,
zero-configuration,
serverless,
transactional
SQL database engine.
It’s very compact and
easy to use and set up.
It’s ideal for testing or if we’re looking to save data quickly.
some sqlite3 disadvantages.
no multi-user capabilities
reads and writes directly to an ordinary disk file.
PostgreSQL
User-defined types
Table inheritance
Asynchronous replication
Multi-user capabilities
Installing an HTTP request client
API clients are packages or libraries that send HTTP requests to an API. The majority supports features such as SSL checking, authentication, and header modification.
we’ll be working with Insomnia. It’s lightweight and simple to use and customize.