尝试在Azure Cloud上部署Python应用程序。使用python3.5.2x64从Cookiecutter template创建WebApp。使用模板中预先配置的Rails.application.routes.draw do
root to: "pages#index"
get "users/profile" => "user_blogs#index", :as => "user_root"
devise_for :users, controllers: { registrations: "users/registrations" }
resources :users do
resources :blogs
end
resources :posts do
resources :comments
end
end
,我面临500错误:
class PostsController < ApplicationController
respond_to :html
before_action :authenticate_user!
expose :blog
expose :post
def show
end
def new
end
def edit
end
def create
post.user = current_user
post.save
respond_with post, location: user_blog_path(post.blog.user, post.blog)
end
def update
post.update(post_params)
respond_with post, location: user_blog_path(post.blog.user, post.blog)
end
def destroy
post.destroy
respond_with post, location: user_blog_path(post.blog.user, post.blog)
end
private
def post_params
params.require(:post).permit(:title, :content, :user_id, :blog_id)
end
end
。
我的web.config
文件:
<handler> scriptProcessor could not be found in <fastCGI> application configuration
我的web.config
:
<configuration>
<system.web>
<customErrors mode="Off"/>
</system.web>
<appSettings>
<add key="PYTHONPATH" value="D:\home\site\wwwroot"/>
<add key="WSGI_HANDLER" value="webapp.wsgi_app"/>
<add key="WSGI_LOG" value="D:\home\LogFiles\python.log"/>
</appSettings>
<system.webServer>
<httpErrors errorMode="Detailed" />
<modules runAllManagedModulesForAllRequests="true" />
<handlers>
<add name="Python FastCGI"
path="*"
verb="*"
modules="FastCgiModule"
scriptProcessor="D:\home\Python35\python.exe|D:\home\Python35\wfastcgi.py"
resourceType="Unspecified"
requireAccess="Script" />
</handlers>
</system.webServer>
</configuration>
使用Azure中的Django应用程序并没有帮助,因为它过时(使用不受支持的webapp.py
,引发def wsgi_app(environ, start_response):
status = '200 OK'
response_headers = [('Content-type', 'text/plain')]
start_response(status, response_headers)
response_body = 'Hello World'
yield response_body.encode()
if __name__ == '__main__':
from wsgiref.simple_server import make_server
httpd = make_server('localhost', 5555, wsgi_app)
httpd.serve_forever()
)。
有什么建议我做错了吗?谢谢。
更新即可。
花了一些时间后,我发现一切都与本机安装的Python(2或3,无关紧要)一起工作,因此似乎IIS没有看到或查看我的Python扩展(已安装)来自Azure Portal btw)。然而,即使使用原生Python,它也不会立即起作用,而是首先抛出Microsoft.Diagnostics
(Python 3.4)或AttributeError: 'module' object has no attribute 'get_virtualenv_handler'
(Python 2.7)。大约15分钟后,神奇地开始工作。我所做的只是改变 Hello World! string。
答案 0 :(得分:0)