wsgi

TemplateSyntaxError: Caught ImportError while rendering: cannot import name utils

寵の児 提交于 2019-12-07 15:21:47
I'm having trouble to get this django application running on my CentOS 6 / Apache/2.2.15. When I run the app I get this error: Traceback (most recent call last): File "/usr/local/lib/python2.7/site-packages/django/core/handlers/wsgi.py", line 272, in __call__ response = self.get_response(request) File "/usr/local/lib/python2.7/site-packages/django/core/handlers/base.py", line 169, in get_response response = self.handle_uncaught_exception(request, resolver, sys.exc_info()) File "/usr/local/lib/python2.7/site-packages/django/core/handlers/base.py", line 203, in handle_uncaught_exception return

Simple Network UDP Listen in Flask or Pyramid

℡╲_俬逩灬. 提交于 2019-12-07 12:14:20
问题 I need to create a web app that displays data provided via periodic incoming UDP packets. The site will be probably be in Flask (possibly Pyramid), deployed under Nginx. How can a I create a very simple background task (basically just socket.recv()) to listen for any incoming packets, and push the data into globally accessible lists? Can I simply spawn a thread from main() to do this, or do I need to use something like Celery or PyRes? Thanks for any guidance. 回答1: You will have to use celery

Python - Overridding print()

梦想与她 提交于 2019-12-07 11:45:14
问题 I'm using mod_wsgi and was wondering if it's possible to over-write the print() command (since it's useless). Doing this doesn't work: print = myPrintFunction Since it's a syntax error. :( 回答1: Print is not a function in Python 2.x, so this is not directly possible. You can, however, override sys.stdout. If you are on Python 3.0 in which print is now a function what you have would then work, assuming you have the right signature. Also see a related question in this site. 回答2: Would import sys

Can i programmatically start a WSGI application server without blocking the main thread of execution?

核能气质少年 提交于 2019-12-07 11:03:55
问题 I'm writing a web application in python, and using lettuce with splinter to write acceptance tests for it. In order to do this, I need to get a wsgi server to start my application in the background, so that the application is available for my test suite. To do this, I've been spinning up a waitress server instance in another thread, for the browser being driven to connect to: def setUp(): base = os.path.dirname(__file__) + "/../../.." world.app = loadapp('config:test.ini', relative_to=base)

Django WGSI paths

梦想的初衷 提交于 2019-12-07 05:25:43
问题 I am having problems setting up wgsi with django. I'm following this http://docs.djangoproject.com/en/dev/howto/deployment/modwsgi/ . Yet I am still really confused as to where to put the .wsgi file and if I need to set the sys.path. I have tried it both directly outside and inside the web root and I can't get anything to work as expected. # /home/ben/public_html/django_test/testproject/apache/django.wsgi: import os import sys os.environ['DJANGO_SETTINGS_MODULE'] = 'testproject.settings'

Python modules autoloader?

北战南征 提交于 2019-12-07 04:01:02
问题 How can I autoload all my modules that kept in different directories and sub directories? I have seen this answer which is using __import__ , but it is still not the autoload that I have in mind. I'm thinking something similar to PHP autoloader. Even better something like Composer autoloader. It seems that autoloader is not a popular thing in Python from the research I have gathered so far (can't be sure as I'm new in Python). Is autoloading something not encourage-able in Python? My autoload

apache2 and mod wsgi : Target WSGI script cannot be loaded as Python module

核能气质少年 提交于 2019-12-07 01:15:20
问题 I am trying to install mod_wsgi on apache2, on ubuntu. So I install libapache2-mod-wsgi package, I activate him with a2enmod. I got a web site (languageAnalyz), that I am trying to use with mod_wsgi. When I call localhost/languageAnalyz, I got an error 500. In apache2 log, I can see this : [Sun Aug 25 11:28:21 2013] [error] [client 127.0.0.1] mod_wsgi (pid=4993): Target WSGI script '/var/www/languageAnalyz/test-wsgi.py' cannot be loaded as Python module. [Sun Aug 25 11:28:21 2013] [error]

Module 'main' has no attribute application — Google App Engine Python with Django

蹲街弑〆低调 提交于 2019-12-07 00:55:35
I have been running into this problem for a short while now and simply can't find a solution anywhere. I am using Google App Engine to run a default Python 2.7 app with Django 1.5 (via GAE SDK) created through PyCharm. I can upload the app successfully, but upon visiting the actual page, I get a Server Error. Then, checking the logs in Google App Engine, I see this: ImportError: <module 'main' from '/base/data/home/apps/s~eloquent-ratio-109701/1.388053784931450315/main.pyc'> has no attribute application After searching the internet for a while, I was able to find a few posts which address this

[深度分析] Python Web 开发框架 Bottle(作者 @Sunng)

别说谁变了你拦得住时间么 提交于 2019-12-07 00:30:22
Bottle 是一个非常精致的WSGI框架,它提供了 Python Web开发中需要的基本支持:URL路由,Request/Response对象封装,模板支持,与WSGI服务器集成支持。整个框架的全部代码约有 2000行,它的核心部分没有其他任何依赖,只要有Python环境就可以运行。 Bottle适用于小型的Web开发,在应用程序规模比较小的情况下可以实现快速开发。但是由于自身功能所限,对于大型的Web程序,Bottle的功能略显不足,程序员需要手动管理模块、数据库、配置等等,与Pylons等框架相比Bottle的优势就难以体现出来了。 快速入门 通过一个简单的、典型的例子描述Bottle的使用: from bottle import Bottle, run, mako_view, request myapp = Bottle ( ) @myapp. get ( '/hello/:name/:count# \\ d+#' ) @mako_view ( 'hello' ) def hello ( name, count ) : ip = request. environ . get ( 'REMOTE_ADDR' ) return dict ( n=name, c= int ( count ) , ip=ip ) run ( app=myapp ) 我们创建一个Bottle对象

Cannot solve mod_wsgi exception in Django setup

喜夏-厌秋 提交于 2019-12-06 18:09:40
问题 I'm working with my hosting provider to get a Django application up and running, but neither of us are very experienced and we've basically hit a complete dead end. I don't have direct access to the conf file but here's how its contents have been described to me: <IfModule mod_wsgi.c> WSGIScriptAlias /fredapp/ /home/fred/public_html/cgi-bin/fredapp/apache/django.wsgi WSGIDaemonProcess fred threads=15 display-name=%{GROUP} python-path=/home/fred/public_html/cgi-bin/fredapp/apache/