回答編集履歴

3

hello.wsgi

2018/01/19 21:14

投稿

umyu
umyu

スコア5846

test CHANGED
@@ -16,20 +16,26 @@
16
16
 
17
17
  def application(environ, start_response):
18
18
 
19
- start_response('200 OK', [('Content-Type', 'text/html')])
19
+ status = '200 OK'
20
20
 
21
- content = """<!DOCTYPE html><head></head><body>
21
+ output = b'Hello World!'
22
22
 
23
- <h1>お疲れ様です。</h1>
24
23
 
25
- </body></html>"""
26
24
 
25
+ response_headers = [('Content-type', 'text/plain'),
26
+
27
- return content.encode('utf-8')
27
+ ('Content-Length', str(len(output)))]
28
+
29
+ start_response(status, response_headers)
30
+
31
+ return [output]
28
32
 
29
33
  ```
30
34
 
31
35
  ■参考情報
32
36
 
37
+ - [hello.wsgi](https://github.com/GrahamDumpleton/mod_wsgi/blob/develop/tests/hello.wsgi)
38
+
33
39
  - [SERVING PYTHON SCRIPTS WITH APACHE MOD_WSGI, PART I](http://koo.fi/blog/2012/12/02/serving-python-scripts-with-apache-mod_wsgi-part-i/)
34
40
 
35
41
  - [Debugging Techniques](http://modwsgi.readthedocs.io/en/develop/user-guides/debugging-techniques.html)

2

encodeを追加

2018/01/19 21:14

投稿

umyu
umyu

スコア5846

test CHANGED
@@ -20,13 +20,11 @@
20
20
 
21
21
  content = """<!DOCTYPE html><head></head><body>
22
22
 
23
- <h1>お疲れ様です。</h1>
23
+ <h1>お疲れ様です。</h1>
24
24
 
25
- </body></html>
25
+ </body></html>"""
26
26
 
27
- """
28
-
29
- return content
27
+ return content.encode('utf-8')
30
28
 
31
29
  ```
32
30
 

1

参考情報を追加

2018/01/19 18:13

投稿

umyu
umyu

スコア5846

test CHANGED
@@ -2,9 +2,15 @@
2
2
 
3
3
 
4
4
 
5
- main.pyに**application メソッドが無い**というメッセジに見えのですが。
5
+ 翻訳
6
6
 
7
+ [Sat Jan 20 01:40:47 2018] [error] [client ::1] mod_wsgi (pid=66536): Target WSGI script '/Applications/MAMP/htdocs/python/main.py' **WSGIアプリケーション 'application'は含まれていません。**
8
+
9
+
10
+
11
+ main.pyに**application メソッドが無い**というエラーメッセージに見えますが。
12
+
7
- main.pyのprint文を以下コードに変てみてはどうでしょうか?
13
+ main.pyのprint文を以下コードに変更してみてはどうでしょうか?
8
14
 
9
15
  ```Python
10
16
 
@@ -26,4 +32,6 @@
26
32
 
27
33
  ■参考情報
28
34
 
29
- [SERVING PYTHON SCRIPTS WITH APACHE MOD_WSGI, PART I](http://koo.fi/blog/2012/12/02/serving-python-scripts-with-apache-mod_wsgi-part-i/)
35
+ - [SERVING PYTHON SCRIPTS WITH APACHE MOD_WSGI, PART I](http://koo.fi/blog/2012/12/02/serving-python-scripts-with-apache-mod_wsgi-part-i/)
36
+
37
+ - [Debugging Techniques](http://modwsgi.readthedocs.io/en/develop/user-guides/debugging-techniques.html)