python - Server side execution (execution back-end image processing ) -
I tried to create a web app with Python django module. The job is if any link goes on, this image will process with the threshold and save it in the server folder.
My code (views.py) is: - PIL Import import image as Tesseract import ctypes import from NP import CV2 import image django.http import HttpResponse import by numpy OS Import ImageDraw def index (request): im_gray = cv2.imread ( 'Rimage.jpg', cv2.CV_LOAD_IMAGE_GRAYSCALE) (correction, im_bw) = cv2.threshold (im_gray, 128, 255, cv2.THRESH_BINARY | cv2. THRESH_OTSU) thrashing = 100 im_bw = cv2.threshold (im_gray, toweling, 255, cv2.THRESH_BINARY) [1] cv2.imwrite ( 'bw_image.png', im_bw) return HttpResponse ( "Hello world. you are in the public opinion index. ")
This code is not working: -
tr Saback file "/usr/local/lib/python2.7/dist-packages/django /core/handlers/base.py" "file get_response 98. resolver_match = resolver.resolve (request.path_info)" / usr / local 343. In the /lib/python2.7/dist-packages/django/core/urlresolvers.py resolution, for their own patterns. Url_patterns: file "/usr/local/lib/python2.7/ district packages / Django / core / urlresolvers.py" url_patterns 372. pattern = getattr (self.urlconf_module, "urlpatterns", self.urlconf_module) file "/ usr / local / lib / python2.7 / dist-packages / django /core/urlresolvers.py "37. __import __ (name import_module) file" /usr/lib/python2.7/importlib/__init__.py "urlconf_module 366 File in "self._urlconf_module = import_module (self.urlconf_name)" / home /meraj/Desktop/project/web/mysite/mysite/urls.py "in & lt; Module & gt; 5. Include url (r '^ polls /', '(polls.urls')), in the file "/usr/local/lib/python2.7/dist-packages/django/conf/urls/__init__.py" include 28. urlconf_module = import_module (urlconf_module) file "/usr/lib/python2.7/importlib/__init__.py" 37. __import__ (name import_module) file "/ home / merge / desktop / project / web / mysite / Polls / Urls.py "in & lt; Module & gt; 3. Import views from elections Exception type: indentation error on / election / exception value: united does not match any external indentation level (views.py, line 20)
Not even wrong This code is being executed locally, but when I try on the Django Framework, it does not work. Am I going in the right direction? I am new to the web framework, so I have no information about it. Thanks in advance
"Locally vs. Django Framework".
Does this mean that you are editing on a machine and copying the file to another? The problem is that according to your output indentation is an error, so maybe this is a space / tab or linebreak problem (a window / a Linux?) If in the past, try to replace all the tabs with empty space in your editor And make sure that you have the correct indentation. If later, try a dos2unix on the file.
Comments
Post a Comment