Introduction
Client-server architecture helps computers talk to each other. One computer (server) gives information, and another (client) asks for it.
Client-server architecture helps computers talk to each other. One computer (server) gives information, and another (client) asks for it.
Client sends a request to Server Server processes the request Server sends back a response to Client
GET /users HTTP/1.1
Host: example.comPOST /login HTTP/1.1 Host: example.com Content-Type: application/json {"username":"user1", "password":"pass"}
This program creates a simple server using Flask. It has two parts:
You can test it by sending requests from a client like a browser or Postman.
from flask import Flask, jsonify, request app = Flask(__name__) users = [{"id": 1, "name": "Alice"}, {"id": 2, "name": "Bob"}] @app.route('/users', methods=['GET']) def get_users(): return jsonify(users) @app.route('/greet', methods=['POST']) def greet_user(): data = request.get_json() name = data.get('name', 'Guest') return jsonify({"message": f"Hello, {name}!"}) if __name__ == '__main__': app.run(debug=True)
The client and server communicate using requests and responses.
Servers can handle many clients at the same time.
Client-server helps keep things organized and secure.
Client-server architecture splits work between two computers.
Clients ask for data; servers send data back.
This setup is common in websites and apps.
/users/123 and the user exists?Pass the test and this pattern moves unknown