mod-python

mod_python equivalent to php exec() command

 ̄綄美尐妖づ 提交于 2020-02-06 12:48:11
问题 what is the mod_python equivalent to the php exec command? $cmd = '/var/www/scripts/test.py' + $parameter $return = exec($cmd) I've tried this but it doesn't return anything varReturn= subprocess.check_output(['/var/www/scripts/resolveID.py ', varParameters) 回答1: Capture the stdout and stderr of the subprocess: from subprocess import Popen, PIPE proc = Popen(['/var/www/scripts/resolveId.py', 'arg1', 'arg2'], stdout=PIPE, stderr=PIPE) stdout, stderr = proc.communicate() 来源: https:/

Browser Detection Python / mod_python?

岁酱吖の 提交于 2020-01-14 10:44:09
问题 I want to keep some statistics about users and locations in a database. For instance, I would like to store "Mozilla","Firefox","Safari","Chrome","IE", etc... as well as the versions, and possibly the operating system. What I am trying to locate from Python is this string; Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.0.14) Gecko/2009090216 Ubuntu/9.04 (jaunty) Firefox/3.0.14 Is there an efficient way to use Python or mod_python to detect the http user agent/browser? 回答1: HTTP_USER_AGENT

django request.POST contains <could not parse>

一笑奈何 提交于 2020-01-13 10:49:27
问题 I am having a django form to get the username,password. when the user posts data, i see that the post dictionary contains the following(traceback), Traceback (most recent call last): File "/usr/lib/python2.4/site-packages/django/core/handlers/base.py", line 111, in get_response response = callback(request, *callback_args, **callback_kwargs) File "/usr/lib/python2.4/site-packages/django/views/decorators/csrf.py", line 39, in wrapped_view resp = view_func(*args, **kwargs) File "/usr/lib/python2

Mod_python error: ImportError: Could not import settings

夙愿已清 提交于 2020-01-12 08:00:07
问题 Trying to get Django to work with Apache, and I'm getting the following error: ImportError: Could not import settings 'MyDjangoApp.settings' (Is it on sys.path? Does it have syntax errors?): No module named MyDjangoApp.settings My Django app is located in /home/user/django/MyDjangoApp/ My httpd.conf Location section looks like: <Location "/MyDjangoApp/"> SetHandler python-program PythonHandler django.core.handlers.modpython SetEnv DJANGO_SETTINGS_MODULE MKSearch.settings PythonOption django

Error while deploying Django on Apache

那年仲夏 提交于 2019-12-31 04:38:21
问题 I have a small Django website which I am trying to run on an Apache 2.2 HTTP-Server. The application is running fine using "python manage.py runserver". Django Version: 1.0.2 final Python: 2.5 OS: Windows 2000 I wen't through the steps described in the documentation and after some fiddling, came out with the following in my httpd.conf. <Location "/therap/"> SetHandler python-program PythonHandler django.core.handlers.modpython SetEnv DJANGO_SETTINGS_MODULE settings PythonOption django.root

apache server cant find static files in Django project

做~自己de王妃 提交于 2019-12-23 15:54:17
问题 I'm trying to upload my code on an apache server using mod_python. I have tried a lot but the server is not able to access my static files (all my images, js and css). Here are my Virtualhost settings: <VirtualHost *:80> ServerName mysite.com ServerAlias www.mysite.com Alias /static/ /home/mysite/products/static/ # RewriteEngine on RewriteCond %{HTTP_HOST} ^www\.mysite\.com RewriteRule (.*) http://mysite.com$1 [R=301,L] # DocumentRoot /home <Directory /home/mysite/> SetHandler mod_python

Restarting a Django application running on Apache + mod_python

落花浮王杯 提交于 2019-12-22 04:28:20
问题 I'm running a Django app on Apache + mod_python. When I make some changes to the code, sometimes they have effect immediately, other times they don't, until I restart Apache. However I don't really want to do that since it's a production server running other stuff too. Is there some other way to force that? Just to make it clear, since I see some people get it wrong, I'm talking about a production environment. For development I'm using Django's development server, of course. 回答1: If possible,

Why can't I disable .htaccess in Apache?

浪尽此生 提交于 2019-12-21 17:16:32
问题 This is the opposite problem from most about which I have read. I am running Ubuntu 8.04 on an Amazon instance with Apache 2.2.8 and I can't figure out why setting AllowOverride to None for root doesn't stop my .htaccess file from being included. I have a sub-directory with hello.py in it and an .htaccess file. When I browse to the file, it works fine with modpython serving the file. If I put some garbage in .htaccess I get a server error, so I know the .htaccess file is being used. Also if I

Calling a Python script from a webpage

不羁的心 提交于 2019-12-13 04:58:06
问题 I've searched around for a while but I can't find a concise explanation of how to do what I want. I have a fairly complex program which I'd like to make a simple web interface for. Ideally there'll be a couple of text fields, "foo" and "bar" on a webpage. When the user clicks submit, a python script "src/script.py" is run, which has access to the contents of these fields somehow. I have apache2 and mod_python. 回答1: If it is a "fairly complex program" you may want to use a small framework that

Django logs: any tutorial to log to a file

谁说胖子不能爱 提交于 2019-12-12 09:58:29
问题 I am working with a django project, I haven't started. The developed working on the project left. During the knowledge transfer, it was told to me that all the events are logged to the database. I don't find the database interface useful to search for logs and sometimes they don't even log(I might be wrong). I want to know, if there is an easy tutorial that explains how to enable logging in Django with minimal configuration changes. Thank you Bala 回答1: If you are talking about the Django