我只想說明,在Windows中,工作正常,但是當我嘗試在我的VPS中部署此腳本時,它會失敗。無法將映射添加到WebPy中的子應用程序
這是有點奇怪,因爲如果我添加一個映射到主Web應用程序實例,它是「mainwebapp」它的工作原理,但每當我將它添加到任何子應用程序它顯示爲webpy「未找到」因爲這個,我的頭靠在牆上。
在Windows中,我有Wamp 2.2。在我的VPS我有CentOS 5,nginx uWsgi和相同的Python(2.7)&從我的Windows Webpy版本。
我幾乎可以肯定這是nginx/uwsgi的問題,因爲當我切換到我的Vps中的apache/mod_wsgi時,它也可以在我的Wamp本地服務器中工作。
到目前爲止,這是我一直在測試的代碼,這是一個非常簡單的一個:
class subappcls:
def GET(self):
return "This will also be shown fine"
sub_mappings = (
"/subpath", subappcls
)
#subclass web app
subwebapp = web.application(sub_mappings, globals())
#mapped clas
class mapped_cls:
def GET(self):
return "this mapped sub app will not be found"
#Here I add mappings:
subwebapp.add_mapping("/mapped_sub_path", mapped_cls
class appcls:
def GET(self):
return "main app"
main_mappings = (
"/subapp", subwebapp,
"/app", appcls
)
mainwebapp = web.application(main_mappings, fvars=globals())
class indexcls:
def GET(self):
return "this will be shown just fine"
mainwebapp.add_mapping("/another",indexcls)
application = mainwebapp.wsgifunc()
當我訪問:
/subapp /子路徑#will工作
/subapp/mapped_sub_path#將無法工作
這將工作得很好:
/應用
/另一
這是uwsgi日誌: *上啓動uWSGI 1.3(64位)[星期二12月4日18時41分52秒2012] 編譯版本:4.1.2 20080704(Red Hat 4.1.2-52)2012年11月24日02:21:31 os:Linux-2.6.18-194.17.4.el5xen#1 SMP Mon Oct 25 16:36:31 EDT 2010 警告:你正在運行uWSGI作爲根! (使用--uid標誌) 你的流程數量限制32832 你的內存頁面大小爲4096字節 檢測最大文件描述符數:1024 鎖引擎:並行線程強大的互斥 uwsgi插座0綁定到UNIX地址/ tmp目錄/app.sock fd 3 Python版本:2.7.3(默認,2012年10月30日,06:37:20)[GCC 4.1.2 20080704(Red Hat 4.1.2-52)] Python線程支持已禁用。你可以啓用它 - 啓用線程*
編輯:我啓用了線程的--enable線程參數,並沒有工作。
在此先感謝。
還只是一個問題,你有沒有試過這種在uwsgi如果運行在集成開發服務器(使用命令
python code.py
)下面的代碼工作? – Uuid你是一個真正的,我有多個子應用程序,我只是關閉主要但不是爲了子應用程序,這真的是修復,非常感謝! – Uuid
我沒有檢查這個uwsgi,但它應該工作。將'web.config.debug'設置爲'False'將全局關閉所有應用程序堆棧的重裝器。 –