FAQ Database Discussion Community


How to stream (yield) text data to jinja2 template for a flask app on pythonanywhere

flask,wsgi,pythonanywhere
I try to implement "streaming contents" on my Pythonanywhere account. It looks more or less to what is shown there: cf. http://flask.pocoo.org/docs/0.10/patterns/streaming/ except that my view is calculating a complex process for maybe one minute and yields its data to my template, where a script is supposed to update some...

Import form current directory in python with mod_wsgi

python,import,wsgi
I am running my python (3.4) scripts using apchae+mod_wsgi with the wsgi-script handler. I found that this uses "/" as the execution path, so for easy file acces I do os.chdir( os.path.dirname(environ['SCRIPT_FILENAME'])) after my script starts up. However, I noticed that for some reason python does not add the current...

Start WSGI script at apache startup

python,apache,flask,wsgi
I have flask script running through WSGI on an apache server. After a server reboot, the apache server is started but the python script is only started at the first request. Is there a way to make it start as soon as the server starts so it runs all the...

How to implement Flask Application Dispatching by Path with WSGI?

python,path,flask,wsgi,dispatch
I would like to use a single domain as a Staging Environment for multiple flask applications that will eventually run on their own domains. Something like: example_staging.com/app1 example_staging.com/app2 example_staging.com/app3 where: example_staging.com/app1 acts same as app1.example_staging.com example_staging.com/app2 acts same as app2.example_staging.com example_staging.com/app3 acts same as app3.example_staging.com or: example_staging.com/app1 acts same as...

Deadlock When Streaming From subprocess.Popen And Using Two Subcommands

python,python-3.x,streaming,subprocess,wsgi
In my wsgi application, I have to call a commandline tool to generate data and sometimes another commandline tool to convert that data. It all works through stdout/stdin. I'm using subprocess and I formerly used communicate, which worked fine but was slower since it's not streaming and trying to convert...

Can Django be configured without httpd.conf modifications?

django,apache,centos,virtualenv,wsgi
So I had someone working with me who setup the server functionality of the Django site. It is working great directly on the IP in the browser. So we just finished building the site, and want to hook up the domain. I checked /etc/httpd/conf/httpd.conf and that file has nothing related...

read wsgi post data with unicode encoding

mod-wsgi,wsgi,python-3.4
How can i read wsgi POST with unicode encoding, this is part of my code : .... request_body_size = int(environ.get('CONTENT_LENGTH', 0)) req = str(environ['wsgi.input'].read(request_body_size)) and from req i read my fileds, this is what i posted : کلمه and this is what i read it from inside of py code:...

Python WSGI Error on Output

python,mod-wsgi,wsgi
My python has become quite rusty as I haven't used it for quite a while and am stuck with an issue I am not able to figure out. The python program should accept a form's data sent by a web page, and return some JSON response codes back to it....

Mocking a method outside of a class

python,unit-testing,mocking,wsgi,assert
I need to write a unit test for credential checking module looks something like below. I apologize I cannot copy the exact code.. but I tried my best to simplify as an example. I want to patch methodA so it returns False as a return value and test MyClass to...

When is CGI/FastCGI required and when it is not

django,angularjs,nginx,cgi,wsgi
This is propably a little noob-question, but I have read enough about CGI/FastCGI/WSGI and still not understood completely, so I decided to ask it. First, I want to say what I have understood. I have understood that CGI is an interface program between a web server (for example Apache or...

Redirect a user to url with WSGI (no framework)

python,python-2.7,redirect,wsgi,wsgiref
I am trying to develop a small web application using python's WSGI. For example, if a user chooses Google they would be redirected to google.com, if they chose Facebook they'd be redirected to facebook.com, etc. from wsgiref.simple_server import make_server from cgi import parse_qs, escape main_html = """ <html> <head><title> Welcome...

Apache2 can not load wsgi.py

django,apache,wsgi
I am using an Ubuntu 14.10 X86_64 system with softwares in below: python 3.4 apache2 libapache2-mod-wsgi-py3 django1.8 I created a project by django1.8 at this path: /var/www/html/koorimeo I've noticed that django-admin startproject will generate a wsgi.py file by default and I haven't change its content. I configured apache2 under the...

WSGIScriptAlias Apache in MAC Yosemite

apache,alias,wsgi,yosemite
Hello I have configured SSL and MAMP finally I succeeded, but now I need to hold a controller server that is in wsgi, I configured the WSGIScriptAlias but the URL is not looking where I access. In the browser I can see the json to configure it to look for...

wsgi nginx error: permission denied while connecting to upstream

sockets,ubuntu,nginx,wsgi,uwsgi
There seem to be many questions on StackOverflow about this but unfortunately nothing has worked for me. I'm getting a 502 bad gateway on nginx, and the following on the logs: connect() to ...myproject.sock failed (13: Permission denied) while connecting to upstream I'm running wsgi and nginx on ubuntu, and...

Reverse Proxy in Python using WSGI

python,proxy,wsgi,reverse-proxy
app, built with Flask. I want to have the following routing : "/" -> my Flask app "/foo/" -> Reverse proxy toward http://bar/ So far, I don't have any reverse proxy, so my application looks like : import app [...] if __name__ == '__main__': app.app.secret_key = 'XXX' app.app.run(debug=True, use_reloader=False) I...

import flask on wsgi virtual host fails

python,apache,flask,wsgi
Having the following directory structure and setup: . ├── app │   ├── __init__.py │   ├── __init__.pyc │   ├── static │   ├── templates │   │   ├── base.html │   │   └── index.html │   ├── views.py │   └── views.pyc ├── flask ├── myapp.wsgi ├── run.py ├── run.pyc └── tmp myapp.wsgi #!/usr/bin/python import sys,...

How to put Django within a subdirectory of a website?

django,apache,mod-wsgi,wsgi
I want to run WordPress at mysite.com/, because it's easier to edit sales copy and such. I want to run my Django site within mysite.com/members/ httpd.conf: <VirtualHost *:80> ServerName mysite.com ServerAlias www.mysite.com DocumentRoot /var/www/mysite.com WSGIDaemonProcess mysite python-path=/var/www/mysite.com/mysite:/var/www/mysite.com/ WSGIProcessGroup mysite WSGIScriptAlias / /var/www/mysite.com/mysite/mysite/wsgi.py </VirtualHost> What exactly do I need to do...

Flask, WSGI, and Global Variables to Hold Database Pool

python,flask,global,wsgi
I'm using WSGI/Apache2 and am trying to declare my database pool on init, to be accessible via a global var from my endpoints. I'm using Redis and Cassandra (DSE, specifically). It's my understanding that both the Redis and DSE libs offer pool management so this shouldn't be an issue. My...

Reraising an exception as an HTTP error in Pyramid

python,http,pyramid,wsgi
I have a web app in python Pyramid which calls various other code in python which may raise an exception. Instead of the user receiving a "500 Internal Error", I'd like them to get a more specific error, for instance if MyException is thrown, show a 503 Error. I tried...

Interfacing BaseHttpServer to WSGI in python

python,google-app-engine,wsgi,pythonanywhere,basehttpserver
I am taking a python course where they use BaseHTTPServer. The code they start with is here from BaseHTTPServer import BaseHTTPRequestHandler, HTTPServer class webServerHandler(BaseHTTPRequestHandler): def do_GET(self): try: if self.path.endswith("/hello"): self.send_response(200) self.send_header('Content-type', 'text/html') self.end_headers() message = "" message += "<html><body>Hello!</body></html>" self.wfile.write(message) print message return except IOError: self.send_error(404, 'File Not Found: %s'...

“Symbol not found: __cg_jpeg_resync_to_restart” with djangostack

python,django,wsgi,osx-yosemite,bitnami
I'm trying to connect Django 1.6.10-0 to a project that was previously running on 1.5. After editing the wsgi.py file in my project to include the project path, I get this error: mod_wsgi (pid=6805): Exception occurred processing WSGI script '/Users/Dreadfort/Documents/MyProject/project/wsgi.py'. Traceback (most recent call last): File "/Applications/djangostack-1.6.10-0/apps/django/lib/python2.7/site-packages/django/core/handlers/wsgi.py", line 187, in...

NGINX with uwsgi and django connection refused

django,nginx,wsgi,uwsgi
Welcome stackoverflowers. I`ve been fighting with setting up nginx with uwsgi with django app... There has to be a small mistake somewhere but I cant find it. Here is my file from pastebin, containing files directly related to my issue and also a console log. I would be very greateful...

python: getfilesystemencoding() returns different value in shell and wsgi

python,mod-wsgi,wsgi
When I type 'sys.getfilesystemencoding()' in shell, I got the result "utf-8" >>> >>> import sys >>> sys.getfilesystemencoding() 'UTF-8' >>> But when I run in a WSGI script , I got the result "ANSI_X3.4-1968" So why is it different?...

My virtualenv is not taking into account ? [apache, mod_wsgi and django]

python,django,apache,mod-wsgi,wsgi
I would like to install a Django website on my Ubuntu VPS with Apache and mod_wsgi. I use a virtualenv. But when I go the mysite.com I get a 500 Internal Server Error and the error.log tells me this: [Sun Jan 25 18:42:36 2015] [error] [client xx.xx.xx.xx] File "/usr/local/lib/python2.7/dist-packages/django/core/cache/backends/memcached.py", line...

can not connect to pymssql from python wsgi with mod_wsgi

linux,mod-wsgi,wsgi,python-3.4,pymssql
I am new in wsgi , and now i can not connect to pymssql , after a while this line appear to error.log: [Mon Feb 02 16:12:06.629874 2015] [wsgi:info] [pid 12257] [client 127.0.0.1:48500] mod_wsgi (pid=12257, process='', application='Alireza.FY|/ii'): Loading WSGI script '/var/www/wsgi/scr.wsgi'., referer: http://localhost/ii and nothing happened after this line of...

How to redirect www to no-www on OpenShift properly?

.htaccess,redirect,openshift,wsgi,no-www
I have an OpenShift Python app running on 730ne.cz and www.730ne.cz and I want the www version to redirect to the non-www. I've added wsgi/.htaccess with the following content: RewriteEngine On RewriteBase / RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC] RewriteRule ^(.*)$ http://%1/$1 [R=301,L] But that ended in infinite redirect loop too http://www.730ne.cz/application/application/application/application......

Excessive Latency on CORS AJAX Request to Local WSGI Server in Chrome

javascript,jquery,python,http,wsgi
Setup Two WSGI servers running locally on different ports. One server returns an html page containing javascript that does a cross-origin ajax request to the other WSGI server using jQuery. origin_server.py Serves the html at http://localhost:9010. #!/usr/bin/env python from wsgiref.simple_server import make_server def origin_html(environ, start_response): status = '200 OK' response_headers...

Callback passed as object property fires twice

javascript,jquery,html,ajax,wsgi
I have a boilerplate ajax call that retrieves and renders tables from a database. I had originally passed multiple arguments, which varied. To generalize the code, I put them all into an options object. Ideally, I would like to pass the callback in the options object as well, but what...

Which mod_wsgi Binary to download?

python,wamp,wsgi
1) I am trying to setup a WAMPServer and am stuck on which file I need to download from the site: http://www.lfd.uci.edu/~gohlke/pythonlibs/#mod_wsgi I am using: Windows 7(64 bit), Apache 2.4.9 and Python 2.7. 2) Also, many of the tutorials I have seen on the matter say to download a .so...

WSGI compliant component with web socket client?

python,wsgi,autobahn,crossbar,python-pulsar
I'm trying to integrate a RESTful responder in a Crossbar application, for which the best fit seems to be a WSGI service. This service ideally should be part of the rest of the pub/sub infrastructure, being able to receive WAMP events on the one hand and answer HTTP requests on...

What is meant by “extending httpd” in the context of mod_python?

python,wsgi
In a highly-upvoted comment to this answer two statements are made: mod_wsgi is for running web apps. ‎ mod_python is for extending httpd. I suppose that the first statement refers to interactive websites as web-apps. But what does the second statement mean? httpd is very commonly the Apache daemon which...

Import Error: No module named Flask

python-3.x,flask,apache2,wsgi
I am getting 500 internal server error when running my server with Flask,apache2, and Python 3.4.2. At first I installed Flask without creating virtual environment, so I thought that that could be a reason. However, I later created virtual environment for my app using: python3.4 -m venv venv source venv/bin/activate...