FAQ Database Discussion Community


Call another python file in the backend

python,python-2.7,mod-wsgi
I've installed "mod_wsgi" and I am experimenting with python on the backend. I have a php background, so I am struggling on making redirects on the backend to another python file, example: This is my test.py, which is called when I go to "http://localhost/": def application(environ, start_response): start_response("301 Redirect", [("Location",...

.htaccess is read but redirect not working

django,apache,.htaccess,mod-wsgi
I am using apache + django + mod_wsgi as server. My goal is to redirect non-www url to www url. I have the mod_rewrite enabled: when executing the command Module rewrite already enabled, I have Module rewrite already enabled The site.conf in sites-available reads <VirtualHost *:80> # Admin email, Server...

flask running in mod_wsgi cannot write to /tmp

python,flask,mod-wsgi
Apache v2.4.12-2 Mod_wsgi v4.4.8-1 Python v3.4.2 python-flask v0.10.1-5 Arch linux - kernel 3.12.36 I'm using mod_wsgi and flask to host a server. I am able to reproduce this issue with the following simplified code and generic .wsgi script: MainServer.py: import flask app = flask.Flask(__name__) @app.before_first_request def initstuff(): test_file = '/tmp/test'...

server internal error with mod_wsgi and apache2

python,django,apache,mod-wsgi
I've been trying to deploy django-oscar's sandbox website on a server with mod_wsgi and apache2. The thing is, whenever I open the website's address, i get a 500 error with the following in my log : [Fri May 22 16:53:48 2015] [error] [client 2.190.60.200] mod_wsgi (pid=28331): Exception occurred processing WSGI...

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?...

how to let the domin ip point to a web2py app instead of the default “welcome” app

apache,mod-wsgi,web2py
I want to enter my app by http://my.domain.ip/ instead of http://my.domain.ip/myapp.should I change the apache config(conf.d/deault.conf) or do something else? I want to bind some domin names to other apps in web2py/applications if this domin ip test success. NameVirtualHost *:80 NameVirtualHost *:443 <VirtualHost *:80> WSGIDaemonProcess web2py user=apache group=apache processes=1 threads=1...

how to improve the performance of Apache with mod_wsgi?

apache,mod-wsgi
Use Apache/2.4.12(Unix) and mod_wsgi-4.4.11 and blow configuration of apache/conf/extra: //httpd-mpm.conf <IfModule mpm_worker_module> StartServers 3 MinSpareThreads 75 MaxSpareThreads 250 ThreadsPerChild 25 MaxRequestWorkers 400 MaxConnectionsPerChild 0 </IfModule> //httpd-vhosts.conf WSGIRestrictEmbedded On <VirtualHost *:443> ServerName form.xxx.com WSGIScriptAlias / /usr/local/apache/services/form/form.wsgi WSGIDaemonProcess paymentform user=test processes=10 threads=5 display-name=%{GROUP} maximum-requests=100...

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...

Apache running on which Port

python,apache,python-2.7,mod-wsgi,httpd.conf
Is there a way to programatically find out which PORT Apache is running on from within a Python program (WEB Application using mod_wsgi) I can always do a grep on httpd.conf but wanted to know if there is some other standard programatic way of achieving this....

Deploy Flask app on Apache Server using mod_wsgi and WinSCP

python,apache,flask,mod-wsgi
I want to deploy my Flask application on an Apache server. I have an account on the server, and have been told that "The server can be used to run scripts and web apps written in Python (using django and mod_wsgi)". I am on Windows, and to transfer files I...

Function attributes in Python

python,django,apache,concurrency,mod-wsgi
I asked this question as continuation of Limit function execution in Python I found a way to do it without threads etc. Just simple checking from time to time. Here is my decorator: def time_limit(seconds): def decorator(func): func.info = threading.local() def check_timeout(): if hasattr(func.info, 'end_time'): if time.time() > func.info.end_time: raise...

BeautifulSoup inside Django view makes WSGI timeout

django,beautifulsoup,mod-wsgi
For a strange reason when I instantiate a BeautifulSoup object inside Django's view, the WSGI timeout. Any help is appreciated as I am banging my head against the wall for hours and cannot find the root of this problem. The view: def index(request): soup = BeautifulSoup('<b>Bold</b>') # Removing this line...

How to install mod_wsgi from lfd in 2015

mod-wsgi,python-wheel
How can I install mod_wsgi from lfd website as it has wheel extension.Whenever I am searching how to install mod_wsgi on wamp the resources tell me to install binary from this site and then keep the mod_wsgi.so file in my wamp directory.

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....

Deploying Django on Apache and WSGI

django,apache,mod-wsgi
Although I have found a bunch of tech support to deploy Django over Apache using WSGI but infact they all have confused me unfortunately, and I couldn't get the Django running. I hope this to be real easy job but being a new comer I am facing difficulties. I have...

Getting Flask to use Python3 (Apache/mod_wsgi)

python-3.x,flask,mod-wsgi
I've got a basic "hello world" Flask app running. I'm on Ubuntu 14.04, using Apache 2.4. I've installed mod_wsgi. I've created a ~/web/piFlask/venv/ to hold a virtualenv-created Python2 with flask installed. However, I wish to have my flaskapp import a Python3.x module I have written. What do I need to...

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...

Mod_wsgi https Error Connection Refused

django,apache,ssl,https,mod-wsgi
My team is developing a REST API to support an iPhone app using Django's REST Framework. It has come time for us to switch from hosting via the development WSGI interface to the mod_wsgi apache interface. We've decided to use mod_wsgi-httpd as the Apache instance. We cannot get mod_wsgi to...

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...

Why does page hang/timeout with apache2, mod_wsgi, django, in virtual environment and under non-privileged user

django,apache,mod-wsgi
When I go to 52.1.65.249, the page hangs or times out. I have a django project located under a non-root user at /home/usrbkto/bkto/projbkto. I have the same problem on two servers running ubuntu 14.04 and python 2.7.8 and ubuntu 15.04 and python 2.7.9. I believe the mod_wsgi on PyPi was...

Apache Internal Server Error with just [:error] [pid #] 1.0 # in error_log

python,apache,flask,mod-wsgi
I'm having Apache serve a Flask app via mod_wsgi. The app is a web form that saves fields to a local file on form submission. Everything runs smoothly other than occasionally on hitting the form submission the server throws an Internal Server error. Also so far I haven't seen anything...

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:...

Django WSGI deployment. cannot import name 'SimpleCookie'

django,mod-wsgi
I am trying to deploy Django site. It runs in development server as intended. When running python under cp virtual environment import succeds as well. But under Apache mod_wsgi I get the folloing error log for the site: [Wed Jun 10 17:26:20.204238 2015] [:info] [pid 18376:tid 140307600816000] mod_wsgi (pid=18376): Attach...

Deploy two Django projects on one Xampp Windows Apache Mod_WSGI server

python,django,windows,apache,mod-wsgi
I want to deploy multiple Django projects on one server. It is Windows 32 bit Xampp. mod_wsgi is 32 bit. python is 32 bit. Django is ver 1.7.3. I have read lots of posts and tried many things but I can't get past this problem. The following error shown in...

Serve Django from root domain with Apache, and also use /var/www/html

django,apache,mod-wsgi
I'm new to Django and Apache, so apologies if my terminology is a bit off. I have a Django app that I'm serving with Apache using mod_wsgi. I used this guide, and just switched to Apache from the Django dev server. In my 000-default.conf file I have this line WSGIScriptAlias...

Installing mod_wsgi for Python3 on Ubuntu

ubuntu,python-3.x,pip,virtualenv,mod-wsgi
Could anyone give me a clear set of instructions for installing mod_wsgi on Ubuntu for Python 3? I did get Flask & mod_wsgi successfully using Python3, and for a brief moment felt happy. ...until I looked at Apache's log and realised that I've run into this problem: https://askubuntu.com/questions/569550/assertionerror-using-apache2-and-libapache2-mod-wsgi-py3-on-ubuntu-14-04-python apt-get is...

deploy django under apache mod_wsgi waiting for localhost

python,django,apache,mod-wsgi
I am deploying a Django project on Apache. and after configuration, I open the "localhost" in the browser, and nothing showed up and the status bar just keep saying "Waiting for localhost". Here is some info. Environment: OS: ubuntu Python: 2.7.3 Django: 1.8.2 Apache: 2.2.21 Django project: /var/www/ocr_service Apache virtualhost:...

Deploy django app with domain and subdomains using mod_wsgi

python,django,apache,subdomain,mod-wsgi
I am new to django and this is my first project in django. So far, I have developed a django app. It is working fluently in my local machine but I’m unable to deploy it online. I have seen many tutorials on internet for deploying the app on server. But...

How do I use a conda environment with mod_wsgi?

python,apache,mod-wsgi,anaconda,conda
My first post, and I'm new to both Python and Apache, so please go easy on me. I have a Python web application in a conda environment that serves up content just fine using Flask. Now I need to serve everything with Apache instead of Flask. I can get Apache...