Server side execution (execution back-end image processing )
Question: I tried to build an web app with python django module. The task is If any one
go to the link it will process image with threshold and save to server folder.

My code is(views.py):-

    
    
    from django.http import HttpResponse
    import numpy as np
    import cv2
    import Image
    from PIL import Image
    import tesseract
    import ctypes
    import os
    import ImageDraw
    
    
    
    def index(request):
        im_gray = cv2.imread('Rimage.jpg', cv2.CV_LOAD_IMAGE_GRAYSCALE)
        (thresh, im_bw) = cv2.threshold(im_gray, 128, 255, cv2.THRESH_BINARY | cv2.THRESH_OTSU)
        thresh = 100
        im_bw = cv2.threshold(im_gray, thresh, 255, cv2.THRESH_BINARY)[1]
        cv2.imwrite('bw_image.png', im_bw)
    
        return HttpResponse("Hello, world. You're at the polls index.")
    

this code is not working error :-

    
    
    Traceback:
    File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py" in get_response
      98.                 resolver_match = resolver.resolve(request.path_info)
    File "/usr/local/lib/python2.7/dist-packages/django/core/urlresolvers.py" in resolve
      343.             for pattern in self.url_patterns:
    File "/usr/local/lib/python2.7/dist-packages/django/core/urlresolvers.py" in url_patterns
      372.         patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
    File "/usr/local/lib/python2.7/dist-packages/django/core/urlresolvers.py" in urlconf_module
      366.             self._urlconf_module = import_module(self.urlconf_name)
    File "/usr/lib/python2.7/importlib/__init__.py" in import_module
      37.     __import__(name)
    File "/home/meraj/Desktop/project/web/mysite/mysite/urls.py" in <module>
      5.     url(r'^polls/', include('polls.urls')),
    File "/usr/local/lib/python2.7/dist-packages/django/conf/urls/__init__.py" in include
      28.         urlconf_module = import_module(urlconf_module)
    File "/usr/lib/python2.7/importlib/__init__.py" in import_module
      37.     __import__(name)
    File "/home/meraj/Desktop/project/web/mysite/polls/urls.py" in <module>
      3. from polls import views
    
    Exception Type: IndentationError at /polls/
    Exception Value: unindent does not match any outer indentation level (views.py, line 20)
    

There is nothing wrong with my code as it is executing locally, but when i
tried on django framework it is not working. Am I going on correct direction ?
I am new to python web framework so I don't have any idea about this. thanks
in advance


Answer: > "locally versus django framework".

Does this mean you are editing on one machine and copying the file to another?
The problem is an IndentationEror, according to your output, so perhaps this
is a space/tab or linebreak issue (one windows/one linux?) If the former, try
replacing all tabs with spaces in your editor and ensuring you have the
indentation correct after. If the latter, try a dos2unix on the file.

