> For the complete documentation index, see [llms.txt](https://yavuzalikorkut.gitbook.io/flask/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://yavuzalikorkut.gitbook.io/flask/flaskin-temel-yapilari-1/request-ve-response-doenguesue/request-hooks.md).

# Request Hooks

Bazen her istek çalıştırılmadan önce veya sonra kodu derlemek daha yararlı olabilir. Örneğin, her istek başlangıcında veritabanı bağlantısı oluşturulması gerekli olabilir veya istekte bulunan kullanıcının kimliği doğrulanmak istenilebilir. Her view fonksiyonunda bu işlemi yapan kodu tekrarlamak veya çoğaltmak yerine her istek aktarılmadan önce veya sonra çağrılacak en yaygın fonksiyonları kaydetmek için Flask seçenekler sunmaktadır. **Request hook'**&#x6C;ar bu noktada devreye girerler. **Request hook**'lar dekoratörler olarak sunulmuşlardır ve desteklediği dört hook şu şekildedir.&#x20;

**before\_request** \
Her istekden önce çalıştırılacak bir fonksiyonu kaydeder.

**before\_first\_request** \
Yalnızca ilk istek çalıştırılmadan önce çalışacak bir fonksiyonu kaydeder. Bu, sunucu başlatma görevlerini eklemenin uygun bir yolu olabilir.

**after\_request** \
Beklenen istisnalar oluşmazsa, her istek sonrasında çalıştırılacak bir fonksiyonu kaydeder.

**teardown\_request** \
Beklenmeyen istisnalar oluşsa bile, her istekden sonra çalışacak bir fonksiyonu kaydeder.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://yavuzalikorkut.gitbook.io/flask/flaskin-temel-yapilari-1/request-ve-response-doenguesue/request-hooks.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
