<commit_before>File handler for django, useful when you want to add control or logic to served files.  
It uses `sendfile` supports on different servers and uses pythonic solution on django development server.  
Currently it supports,  

* Apache  
* Nginx  
* LightHttpd  
* Caddy  

# INSTALLATION  

  use pip to install package:  
  `pip install -e git+https://github.com/instapk/django-fileprovider.git@0.1#egg=django-fileprovider`  

* add `fileprovider` to django `INSTALLED_APPS` section.  
* add `fileprovider.middleware.FileProviderMiddleware` to `MIDDLEWARE_CLASSES` section
* set django `settings` file with `FILEPROVIDER_NAME` any of  available providers {'python', 'nginx', 'apache', 'lighthttpd', 'caddy', }

# USAGE  

 on django views where file response is required, fill response header `X-File` with absolute file path  
 for example,  

 ```python  
      
    def hello(request):
        response = HttpResponse()
        response['X-File'] = '/absolute/path/to/file'
        return response
 ```<commit_msg>add code example for settings<commit_after>File handler for django, useful when you want to add control or logic to served files.  
It uses `sendfile` supports on different servers and uses pythonic solution on django development server.  
Currently it supports,  

* Apache  
* Nginx  
* LightHttpd  
* Caddy  

# INSTALLATION  

  use pip to install package:  
  `pip install -e git+https://github.com/instapk/django-fileprovider.git@0.1#egg=django-fileprovider`  

* add `fileprovider` to django `INSTALLED_APPS` section.  
* add `fileprovider.middleware.FileProviderMiddleware` to `MIDDLEWARE_CLASSES` section
* set django `settings` file with `FILEPROVIDER_NAME` any of  available providers {'python', 'nginx', 'apache', 'lighthttpd', 'caddy', }  

 ```python  
    
    # or you can put FILEPROVIDER_NAME as python in your local settings file  
    if settings.DEBUG:
        FILEPROVIDER_NAME = "python"
    else:
        # or apache, lighthttpd, caddy
        FILEPROVIDER_NAME = "nginx"

 ```

# USAGE  

 on django views where file response is required, fill response header `X-File` with absolute file path  
 for example,  

 ```python  
      
    def hello(request):
        response = HttpResponse()
        response['X-File'] = '/absolute/path/to/file'
        return response
 ```
{'fraction_non_alphanumeric': 0.09153416415986249, 'fraction_numerical': 0.0017189514396218307, 'mean_word_length': 3.494208494208494, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1705447', 'n_tokens_mistral': 705, 'n_tokens_neox': 684, 'n_words': 232}