简体   繁体   English

无法更改Python Web.py应用程序Linode示例

[英]Can't change Python Web.py application Linode example

I am following this web.py Hello World example: 我正在遵循以下web.py Hello World示例:

https://library.linode.com/web-servers/nginx/python-uwsgi/ubuntu-12.04-precise-pangolin#sph_more-information https://library.linode.com/web-servers/nginx/python-uwsgi/ubuntu-12.04-precise-pangolin#sph_more-information

Now I get the "Hello World!" 现在,我得到了“ Hello World!” example from above page perfectly to run in my Browser, but when I want to change the application to my need, eg make a fully AJAX app out of it like this: 完美地在上面的示例中可以在浏览器中运行,但是当我想根据需要更改应用程序时,例如,像这样制作一个完整的AJAX应用程序:

urls = ('/(.*)', 'Index')

application = web.application(urls, globals())

web.config.debug = True

class Index:
def POST(self):
    content = web.input(_method='post')
    return 'Ajax Test Data'

if __name__ == '__main__':application.run()

I get the following error (even if I make minor changes to the "application" function from Linode) 我收到以下错误(即使我对Linode的“应用程序”功能进行了较小的更改)

uWSGI Error uWSGI错误

Python application not found 找不到Python应用程式

How can I get this to work with my own code? 如何使它与我自己的代码一起使用?


I uninstalled the Debian packages and installed the pip package with build-in Python. 我卸载了Debian软件包,并使用内置Python安装了pip软件包。 I also had to clean up / unify my .ini and -xml configuration files. 我还必须清理/统一我的.ini和-xml配置文件。

I then started my app with 然后,我以

uwsgi -s /tmp/uwsgi.sock -w app

The biggest help came from this document 最大的帮助来自此文档

However, I encountered a web module not found error , so I rolled back to the Linode example and am currently fiddling around with it, still trying to get my app called from inside the application wrapper. 但是,我遇到了一个web module not found error ,因此我回滚到Linode示例,目前正在摆弄它,仍然尝试从应用程序包装器内部调用我的应用程序。

Hi Look at this stackoverflow post: uwsgi error python application not found 嗨,看看这个stackoverflow帖子: uwsgi错误找不到python应用程序

You need to kill the old uWSGI process, which is searching for the old instance of the app, which no longer exists because you changed it. 您需要终止旧的uWSGI进程,该进程正在搜索应用程序的旧实例,该旧实例不再存在,因为您对其进行了更改。

Instead of running the app with if __name__ == '__main__':application.run() , you need to "export" WSGI application to uWSGI. 代替使用if __name__ == '__main__':application.run()运行应用if __name__ == '__main__':application.run() ,您需要将WSGI应用程序“导出”到uWSGI。 By default uWSGI looks for a WSGI callable named application , but the application you have is not a WSGI callable. 默认情况下,uWSGI查找WSGI可调用的命名application ,但是您拥有的application不是WSGI可调用的。 So remove if __name__ == '__main__':application.run() and replace application = web.application(urls, globals()) with application = web.application(urls, globals()).wsgifunc() . 因此,请删除if __name__ == '__main__':application.run()然后将application = web.application(urls, globals())替换为application = web.application(urls, globals()).wsgifunc()

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM