ホームページ >バックエンド開発 >Python チュートリアル >python在不用框架的情况下如何写网站后台?
python在不用框架的情况下如何写网站后台
<code class="language-python"><span class="k">def</span> <span class="nf">simple_app</span><span class="p">(</span><span class="n">environ</span><span class="p">,</span> <span class="n">start_response</span><span class="p">):</span>
<span class="n">status</span> <span class="o">=</span> <span class="s">'200 OK'</span>
<span class="n">response_headers</span> <span class="o">=</span> <span class="p">[(</span><span class="s">'Content-type'</span><span class="p">,</span> <span class="s">'text/plain'</span><span class="p">)]</span>
<span class="n">start_response</span><span class="p">(</span><span class="n">status</span><span class="p">,</span> <span class="n">response_headers</span><span class="p">)</span>
<span class="k">return</span> <span class="p">[</span><span class="s">'Hello world!</span><span class="se">\n</span><span class="s">'</span><span class="p">]</span>
</code>
Python自带CGI库,就叫cgi