Skip to content
Snippets Groups Projects
Commit f0012230 authored by Empiriker's avatar Empiriker
Browse files

close db connection after request

parent 1f085125
No related branches found
No related tags found
No related merge requests found
...@@ -19,10 +19,9 @@ def index(): ...@@ -19,10 +19,9 @@ def index():
@app.route('/search/<wiktlang>/<wordlang>/<word>', methods=['GET']) @app.route('/search/<wiktlang>/<wordlang>/<word>', methods=['GET'])
def search(wiktlang, wordlang, word): def search(wiktlang, wordlang, word):
en_wiktextract = Wiktextract("en", "en")
wikicode = get_wikicode(word, wiktlang) wikicode = get_wikicode(word, wiktlang)
if wikicode: if wikicode:
en_wiktextract = Wiktextract("en", wordlang)
try: try:
resp = en_wiktextract.parse_page(word, wikicode) resp = en_wiktextract.parse_page(word, wikicode)
return jsonify(resp) return jsonify(resp)
...@@ -41,6 +40,8 @@ def search(wiktlang, wordlang, word): ...@@ -41,6 +40,8 @@ def search(wiktlang, wordlang, word):
</html>""" </html>"""
status = 404 status = 404
mimetype='text/html' mimetype='text/html'
finally:
en_wiktextract.page_handler.wxr.wtp.db_conn.close()
else: else:
resp = f"""<!doctype html> resp = f"""<!doctype html>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment