How do I stop getting ImportError: Could not import settings ‘mofin.settings’ when using django with wsgi?

This can also happen if you have an application (subdirectory to the project with an init file in it) named the same thing as the project. Your settings.py file may be in your project folder, but it seems that a part of the django system looks first for a module inside the project by the … Read more

Target WSGI script cannot be loaded as Python module

For me the problem was wsgi python version mismatch. I was using python 3, so: $ sudo apt-get remove libapache2-mod-python libapache2-mod-wsgi $ sudo apt-get install libapache2-mod-wsgi-py3 Warning from @alxs before you copy/paste these commands: If there are python 2 projects running on the server that use wsgi and apache, the above commands will effectively shut … Read more

Print raw HTTP request in Flask or WSGI

Yes, Flask is a WSGI application, so it is trivial to wrap your app in an extra layer that logs the request: import pprint class LoggingMiddleware(object): def __init__(self, app): self._app = app def __call__(self, env, resp): errorlog = env[‘wsgi.errors’] pprint.pprint((‘REQUEST’, env), stream=errorlog) def log_response(status, headers, *args): pprint.pprint((‘RESPONSE’, status, headers), stream=errorlog) return resp(status, headers, *args) return … Read more

Differences and uses between WSGI, CGI, FastCGI, and mod_python in regards to Python?

A part answer to your question, including scgi. What’s the difference between scgi and wsgi? Is there a speed difference between WSGI and FCGI? How Python web frameworks, WSGI and CGI fit together CGI vs FCGI Lazy and not writing it on my own. From the wikipedia: http://en.wikipedia.org/wiki/FastCGI Instead of creating a new process for … Read more

WSGI vs uWSGi with Nginx [closed]

Ok, guys this confusion is because of lack of detail from several sources, and the naming of these protocols, and what WSGI actually is. Summary: WSGI and uwsgi both ARE protocols, not servers. It is used to communicate with web servers for load balancing and especially to take advantage of extra features that pure HTTP … Read more

Python : How to parse the Body from a raw email , given that raw email does not have a “Body” tag or anything

To be highly positive you work with the actual email body (yet, still with the possibility you’re not parsing the right part), you have to skip attachments, and focus on the plain or html part (depending on your needs) for further processing. As the before-mentioned attachments can and very often are of text/plain or text/html … Read more