python - 设置 Pyramid Web 框架 | FCGI 共享主机

标签 python fastcgi pyramid

如何在我的 ~/public_html 中创建一个简单的 FCGI 程序,该程序将被执行,将网络请求分派(dispatch)到我的 Pyramid 网站?

在 django 中,使用下面的代码对我来说效果很好:

#!/usr/local/bin/python2.6

import sys
import os

sys.path.append('/home/username/local/lib/python2.6/site-packages')

os.environ['DJANGO_SETTINGS_MODULE'] = 'myproj.settings'

from django.core.servers.fastcgi import runfastcgi
runfastcgi(method="threaded", daemonize="false")

我现在被困住了。顺便说一句,这是我学习 Pyramid 的第二天。

最佳答案

我自己没有使用过 FastCGI,但是将基于 Paster 的 WSGI 应用程序连接到 FastCGI 的指南应该是相同的(即 Pylons、TurboGears、Pyramid,都使用 Paster 进行 WSGI)。

我发现对我来说似乎有意义的指南位于:http://turbogears.org/2.1/docs/main/Deployment/FastCGI.html

Hook 任何基于 Paster 的 wsgi 应用程序的关键是dispatch.fcgi 文件...

#!/usr/bin/env python
myapp = '/usr/local/myapp'
inifile = 'production.ini'
import sys, os
sys.path.insert(0, myapp)
from paste.deploy import loadapp
wsgi_app = loadapp('config:' + myapp + '/' + inifile
if __name__ == '__main__':
    from flup.server.fcgi import WSGIServer
    WSGIServer(wsgi_app).run()

关于python - 设置 Pyramid Web 框架 | FCGI 共享主机,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5062923/

相关文章:

python - 安装pyaudio时,pip在/usr/local/include中找不到portaudio.h

python - "unrecognized .svn/entries format"使用扩建

perl - 如何在 nginx 错误日志中获取 perl 脚本错误(Nginx with FCGIwrap)

python - 将 Mako 与 Pyramid 一起使用会导致错误

python - 如何用Python中的美丽汤替换html页面中的特定文本行

python - 使用 format 方法打印一个整洁的乘法表

c - 在 C 中使用 FastCGI 访问 PUT 或 POST 请求的主体

Java PHP FastCGI SocketException : Connection Reset on reading data

postgresql - 使用sqlalchemy + postgresql时如何在 celery 中回滚异常

python - 过滤 SQLAlchemy 关系