<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="et">
	<id>http://www.lambda.ee/w/index.php?action=history&amp;feed=atom&amp;title=Pythoni_http_serveriteegi_kasutamine</id>
	<title>Pythoni http serveriteegi kasutamine - Redigeerimiste ajalugu</title>
	<link rel="self" type="application/atom+xml" href="http://www.lambda.ee/w/index.php?action=history&amp;feed=atom&amp;title=Pythoni_http_serveriteegi_kasutamine"/>
	<link rel="alternate" type="text/html" href="http://www.lambda.ee/w/index.php?title=Pythoni_http_serveriteegi_kasutamine&amp;action=history"/>
	<updated>2026-10-28T17:06:03Z</updated>
	<subtitle>Selle lehekülje redigeerimiste ajalugu</subtitle>
	<generator>MediaWiki 1.43.11</generator>
	<entry>
		<id>http://www.lambda.ee/w/index.php?title=Pythoni_http_serveriteegi_kasutamine&amp;diff=19488&amp;oldid=prev</id>
		<title>Tammet – 1. veebruar 2022, kell 07:01</title>
		<link rel="alternate" type="text/html" href="http://www.lambda.ee/w/index.php?title=Pythoni_http_serveriteegi_kasutamine&amp;diff=19488&amp;oldid=prev"/>
		<updated>2022-02-01T07:01:52Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;et&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;←Vanem redaktsioon&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Redaktsioon: 1. veebruar 2022, kell 09:01&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l15&quot;&gt;15. rida:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;15. rida:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;logfile=&amp;quot;httplog&amp;quot; # here server logs the requests&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;logfile=&amp;quot;httplog&amp;quot; # here server logs the requests&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;#logfile=&amp;quot;/dev/null&amp;quot;  &lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;#logfile=&amp;quot;/dev/null&amp;quot;  &lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-added&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;# ====== globals used during work ========&lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-added&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-added&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;nlp=None # at startup nlp is assigned the stanza pipeline&lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-added&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;# === request processing ===&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;# === request processing ===&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;

&lt;!-- diff cache key lambdadb:diff:1.41:old-19487:rev-19488:php=table --&gt;
&lt;/table&gt;</summary>
		<author><name>Tammet</name></author>
	</entry>
	<entry>
		<id>http://www.lambda.ee/w/index.php?title=Pythoni_http_serveriteegi_kasutamine&amp;diff=19487&amp;oldid=prev</id>
		<title>Tammet: Uus lehekülg: &#039;&lt;pre&gt; #!/usr/bin/env python3   # ======= imports =======  import sys from http.server import BaseHTTPRequestHandler, HTTPServer from urllib.parse import unquote  # ======= config...&#039;</title>
		<link rel="alternate" type="text/html" href="http://www.lambda.ee/w/index.php?title=Pythoni_http_serveriteegi_kasutamine&amp;diff=19487&amp;oldid=prev"/>
		<updated>2022-02-01T07:01:11Z</updated>

		<summary type="html">&lt;p&gt;Uus lehekülg: &amp;#039;&amp;lt;pre&amp;gt; #!/usr/bin/env python3   # ======= imports =======  import sys from http.server import BaseHTTPRequestHandler, HTTPServer from urllib.parse import unquote  # ======= config...&amp;#039;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Uus lehekülg&lt;/b&gt;&lt;/p&gt;&lt;div&gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/usr/bin/env python3&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# ======= imports =======&lt;br /&gt;
&lt;br /&gt;
import sys&lt;br /&gt;
from http.server import BaseHTTPRequestHandler, HTTPServer&lt;br /&gt;
from urllib.parse import unquote&lt;br /&gt;
&lt;br /&gt;
# ======= configuration globals ======&lt;br /&gt;
&lt;br /&gt;
host_name=&amp;quot;localhost&amp;quot;&lt;br /&gt;
server_port=8080&lt;br /&gt;
logfile=&amp;quot;httplog&amp;quot; # here server logs the requests&lt;br /&gt;
#logfile=&amp;quot;/dev/null&amp;quot; &lt;br /&gt;
&lt;br /&gt;
# ====== globals used during work ========&lt;br /&gt;
&lt;br /&gt;
nlp=None # at startup nlp is assigned the stanza pipeline&lt;br /&gt;
&lt;br /&gt;
# === request processing ===&lt;br /&gt;
&lt;br /&gt;
class MyServer(BaseHTTPRequestHandler):&lt;br /&gt;
  def do_GET(self):&lt;br /&gt;
    text=unquote(self.path) # urldecode &lt;br /&gt;
    result=text # to make the server do smth useful, modify here&lt;br /&gt;
    self.send_response(200)&lt;br /&gt;
    self.send_header(&amp;quot;Content-type&amp;quot;, &amp;quot;text/plain&amp;quot;)&lt;br /&gt;
    self.end_headers()    &lt;br /&gt;
    self.wfile.write(bytes(&amp;quot;%s\n&amp;quot; % result, &amp;quot;utf-8&amp;quot;))&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# ====== starting ======&lt;br /&gt;
&lt;br /&gt;
if __name__ == &amp;quot;__main__&amp;quot;:   &lt;br /&gt;
  print(&amp;quot;Server started http://%s:%s&amp;quot; % (host_name, server_port))&lt;br /&gt;
  webServer = HTTPServer((host_name, server_port), MyServer)&lt;br /&gt;
  try:&lt;br /&gt;
    buffer = 1&lt;br /&gt;
    sys.stderr = open(logfile, &amp;#039;w&amp;#039;, buffer)&lt;br /&gt;
    webServer.serve_forever()&lt;br /&gt;
  except KeyboardInterrupt:&lt;br /&gt;
    pass&lt;br /&gt;
&lt;br /&gt;
  &lt;br /&gt;
  webServer.server_close()&lt;br /&gt;
  print(&amp;quot;Server stopped.&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
# ===== the end ======&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Tammet</name></author>
	</entry>
</feed>