2016-12-26 7 views
0

私はAzureでPythonを初めて使用しています。私は以下のように私のwwwrootディレクトリに座っている3つのファイルがあります。フォームからいくつかのフィールドをPOSTし、CGIモジュールでそれらを取得したいだけです。これはApacheサーバー上で正常に動作しますが、空のFieldStorageインスタンスをAzureに返します。Microsoft AzureでフォームデータをPythonスクリプトに投稿するにはどうすればよいですか?

index.py

import cgi 

def main(environ, start_response): 

    markup_file = open("markup.txt") 
    markup = markup_file.read() 
    markup_file.close() 

    fields = cgi.FieldStorage() 

    start_response(b"200 OK", [(b"Content-Type", b"text/html")]) 
    yield (markup + str(fields)).encode("utf-8") 

markup.txt

<html> 
<body> 
    <form action="" method="post"> 
     Message: <input type="text" name="message" /> 
     <input type="submit" value="Submit" /> 
    </form> 
</body> 
</html> 

web.configファイル

<configuration> 
    <appSettings> 
     <add key="pythonpath" value="D:\home\site\wwwroot" /> 
     <add key="WSGI_HANDLER" value="index.main" /> 
    </appSettings> 
</configuration> 

confがあります私が紛失している何か他の明白なものか?

答えて

0

あなたのコードによると、CGIスクリプトではなくWSGIハンドルスクリプトのようです。

だからあなたのコードを書き換えて、それを再配備する公式文書Configuring Python with Azure App Service Web AppsのセクションWSGI Handle & Web.configに従ってください。

Azure WebサイトでCGIを使用する必要がある場合は、MS MVPのblogが役立ちます。

関連する問題