From 67a3be50d36b76b49ae5d1d95376eb922497e7e1 Mon Sep 17 00:00:00 2001
From: Stephane Bortzmeyer <stephane+framagit@bortzmeyer.org>
Date: Wed, 2 Aug 2023 18:27:04 +0200
Subject: [PATCH] Production search engine

---
 search.py | 11 +++--------
 1 file changed, 3 insertions(+), 8 deletions(-)

diff --git a/search.py b/search.py
index 58eb52c..f53cb75 100755
--- a/search.py
+++ b/search.py
@@ -3,7 +3,6 @@
 # You can test it with:
 # curl --request POST  --data string=foobar\&what=language http://localhost:4000
 
-import wsgiref.simple_server as server
 import urllib.parse
 
 # PostgreSQL interface
@@ -12,7 +11,6 @@ import psycopg2
 # HTML templates http://www.yattag.org/
 from yattag import Doc
 
-PORT = 4000
 REDIRECTION_URL = "https://www.langtag.net/registries/registry-html" # For
 # local testing: Firefox apparently does not accept a redirect to a
 # file.
@@ -119,9 +117,6 @@ def application(environ, start_response):
                         text("\"%s\" not found\r\n" % term)
     return pack(start_response, status, title, doc, headers)
 
-if __name__ == "__main__":
-    conn = psycopg2.connect("dbname=lsr")
-    cursor = conn.cursor()
-    httpd = server.make_server("", PORT, application)
-    print("Listening on port %s" % PORT)
-    httpd.serve_forever()
+# Initialize
+conn = psycopg2.connect("dbname=lsr")
+cursor = conn.cursor()