### Client vs Server
Speakers
1. What is a client and what is a server? (Mohamed)
2. Can something be both a client and a server? (Danilo)
3. What kind of code should be run on a server instead of a browser? (Anna)
---
### What is client server
<iframe src="https://giphy.com/embed/sMKedUx9w9m8OGwXi6" width="280" height="284" frameBorder="0" class="giphy-embed" allowFullScreen></iframe>
>"A client of a professional person or organization is a person or company that receives a service"
---
### Client request
<iframe src="https://giphy.com/embed/dwmNhd5H7YAz6" width="150" height="150" frameBorder="0" class="giphy-embed" allowFullScreen></iframe>
> When requesting a file via HTTP, clients must provide the file's URL.
> The web server must answer every HTTP request, at least with an error message.
---
###### Introduction to web server
<iframe src="https://giphy.com/embed/9igGG6KxpY0eY0Sr5u" width="280" height="260" frameBorder="0" class="giphy-embed" allowFullScreen></iframe>
1. Upon receiving a request, an HTTP server first checks if the requested URL matches an existing file.
2. If so, the web server sends the file content back to the browser. If not, an application server builds the necessary file.
---
### Introduction to web server
<iframe src="https://giphy.com/embed/JR5gt4Ju9gswpwkuRY" width="250" height="250" frameBorder="0" class="giphy-embed" allowFullScreen></iframe>
> "The 404 error is so common that some web designers devote considerable time and effort to designing 404 error pages"
<p><a href="https://unsplash.com/@dogse"> Example </a></p>
---
### HTTP
<iframe src="https://giphy.com/embed/cOVIMXlc3A1QvbzhmY" width="280" height="280" frameBorder="0" class="giphy-embed" allowFullScreen></iframe>
Usually only clients make HTTP requests, and only to servers. Servers respond to a client's HTTP request. A server can also populate data into a client cache, in advance of it being requested, through a mechanism called a server push.
---
### Environment
<iframe src="https://giphy.com/embed/xTiTnM6WqhU5bcOxXy" width="277" height="280" frameBorder="0" class="giphy-embed" allowFullScreen></iframe>
though it is possible for the a machine to act as a server and a client this is very unlikely.
---
### Hosting
<iframe src="https://giphy.com/embed/LTFA9idQ7d2AGBIETw" width="280" height="270" frameBorder="0" class="giphy-embed" allowFullScreen></iframe>
Usually a client can't host a large amount of data but in some situations a user can install a web server application for hosting a site in their os and simultaneously access the site as a client.
---
### server
<iframe src="https://giphy.com/embed/GWRfIcwpwJX6E" width="280" height="238" frameBorder="0" class="giphy-embed" allowFullScreen></iframe>
Whereas the server can act as a client for example a server of FB can send a request to Google servers.
---
### Handling data
<!--  -->
<iframe src="https://giphy.com/embed/1Teev5UHUQDYRAmXZd" width="280" height="280" frameBorder="0" class="giphy-embed" allowFullScreen></iframe>
Server side code handles tasks like validating submitted data and requests, using databases to store and retrieve data and sending the correct data to the client.
---
### Dynamically generating webpages

Because they have access to the database the server can serve webpages dynamically to the client based on search parameters, user inputs etc.
---
### Storing secrets

Server side scripts are usually more secure than browser side code. They are used to store secrets (database credentials, api keys, etc).
---
### User validation

Validating data on the server side reduces the chance of malicious inputs to the database.
---
Note - combining this with initial client side validation with HTML5 input types and pattern attribute is a better user experience.

{"metaMigratedAt":"2023-06-16T11:21:44.004Z","metaMigratedFrom":"YAML","title":"Client vs Server","breaks":true,"slideOptions":"{\"theme\":\"solarized\",\"transition\":\"fade\"}","contributors":"[{\"id\":\"f7800be7-93b6-4348-a3ac-879d43ddafa4\",\"add\":1361,\"del\":267},{\"id\":\"0a3ab15b-3310-4524-96d0-8240b9d0005e\",\"add\":6903,\"del\":4777},{\"id\":\"173c5ca6-dd9a-4147-90c5-ad6929e6d625\",\"add\":1057,\"del\":37}]"}