WSGI
web server gateway interfaceの略。pythonでの規格 ( asynchronous server gateway if ASGI も出てきてる) 環境と response用の関数を引数にとって、
response用の関数に、
statusコードと contentTypeを引数にしてにして実行
この関数の中身を記述する際に、returnでかえすものが、http の bodyにする。
大まかには、この3つ?をみたす、関数であればよい?
The environ parameter is a dictionary object, containing CGI-style environment variables.
The start_response parameter is a callable accepting two required positional arguments, and one optional argument.
The status parameter is a status string of the form "999 Message here", and response_headers is a list of (header_name, header_value) tuples describing the HTTP response header
The start_response callable must return a write(body_data) callable that takes one positional parameter:
これ以上は、pass
code:python
def application(environ, start_response):
return 'Hello, world'
returnは、iterableでなくてもよいのかも。stringもiterableで、 逆?にlen() 1の iterableは、 ['my string'] みたなものか pep3333より
Under some circumstances, however, the server or gateway may be able to either generate a Content-Length header, or at least avoid the need to close the client connection. If the application does not call the write() callable, and returns an iterable whose len() is 1, then the server can automatically determine Content-Length by taking the length of the first bytestring yielded by the iterable.
具体例:
WSGI(gunicorn) App(falcon) WebServer(nginx)
この組み合わせは popular