كيف يتحول الطلب إلى استجابة
تتبّع دورة الذهاب والإياب من العميل إلى العرض ثم الاستجابة.
كيف يتحول الطلب إلى استجابة درس مجاني في Flask Academy على CoddyKit. هذا هو الدرس 2 من أصل 4. يمكنك قراءة الدرس كاملاً أدناه مجاناً — ثم تمرن عليه مباشرة في المتصفح باستخدام محرر أكواد مدمج ومدرس ذكاء اصطناعي متاح 24/7. هذا الدرس جزء من مسار التعلم في Flask Academy، وتقدمك يتزامن عبر الويب وتطبيق CoddyKit. تتضمن دورة Flask Academy 4 دروس في المجموع.
بعض أجزاء هذا الدرس لم تُترجم بعد وتظهر باللغة الإنجليزية.
The Round Trip
Every page view is a round trip: the browser sends a request, your server does work, and a response travels back. Let us trace that journey.
It Starts with a Request
A user clicks a link, and the browser sends an HTTP request. It carries the method, the URL path, and some headers describing the client.
Flask Matches the URL
Flask reads the path and finds the matching route. If no route matches, you get a 404 before any view function ever runs.
Your View Function Runs
Once matched, Flask calls your view function. This is where your code runs: read input, do logic, and decide what to send back.
@app.route("/time")
def time():
return "It is now"The Request Object
Inside the view, the request object holds everything the client sent. You import it from Flask to read details about the incoming call.
from flask import requestBuilding the Body
Your function returns a value, and that value becomes the response body. It can be text, HTML, or JSON depending on what you build.
The Response Object
Flask wraps your return value in a response object. That object bundles the body together with a status code and headers.
Status Codes Travel Back
Every response carries a status code. A 200 means success, while a 404 or 500 signals that something went wrong along the way.
Headers Describe the Reply
Response headers describe the body, like its content type and length. The browser reads them to know how to render what you sent.
The Browser Renders It
Finally the browser receives the response, reads the headers, and paints the body on screen. The round trip is complete.
One Request, One Response
The rule is simple: each request gets exactly one response. Your view runs, returns once, and Flask ships that single reply back.
Quick Check
Trace the request cycle in your head, then answer.
Recap
You traced the cycle: request in, route match, view runs, response out. Knowing this flow makes every Flask bug far easier to find. 🔁
الأسئلة الشائعة
هل درس «كيف يتحول الطلب إلى استجابة» مجاني؟
نعم — نص درس «كيف يتحول الطلب إلى استجابة» كامل متاح مجاناً هنا على الويب. لتمرينه بشكل تفاعلي (محرر أكواد مدمج ومدرس ذكاء اصطناعي متاح 24/7) وفتح باقي دورة Flask Academy، انتقل إلى CoddyKit PRO. تتضمن دورة Flask Academy 4 دروس في المجموع.
ماذا ستتعلم في «كيف يتحول الطلب إلى استجابة»؟
تتبّع دورة الذهاب والإياب من العميل إلى العرض ثم الاستجابة. تتمرن على Flask Academy مع أكواد عملية تشغلها مباشرة في المتصفح، ومدرس ذكاء اصطناعي متاح 24/7 يجيب على أسئلتك أثناء عملك.
هل أحتاج إلى خبرة سابقة لأبدأ Flask Academy؟
لا تُشترط خبرة سابقة. Flask Academy على CoddyKit منظم للمبتدئين حتى المتقدمين، لذا يمكنك البدء من هنا أو من البداية والتقدم بسرعتك الخاصة. هذا هو الدرس 2 من أصل 4.
كم من الوقت يستغرق درس «كيف يتحول الطلب إلى استجابة»؟
معظم دروس CoddyKit تستغرق حوالي 5–10 دقائق. كل منها موجز وتفاعلي، لذا تحرز تقدماً مستمراً وتستأنف من حيث توقفت عبر الويب والتطبيق.
هل يمكنني كتابة وتشغيل أكواد في درس Flask Academy هذا؟
نعم. كل درس في Flask Academy يتضمن محرر أكواد مدمج، لذا تكتب وتشغل أكواداً حقيقية مباشرة في متصفحك وتحصل على تعليقات فورية من الذكاء الاصطناعي — بدون إعداد محلي.
جميع الدروس في هذه الدورة
- المزيّن @app.route
- كيف يتحول الطلب إلى استجابة
- إرجاع السلاسل وHTML ورموز الحالة
- مسارات متعددة في تطبيق واحد