diff --git a/wikstraktor_server.py b/wikstraktor_server.py index 804b03db9a25e2711808d1a7025967bc807813e0..0aae88625206bc451e97ab428c705ee63e8928dd 100755 --- a/wikstraktor_server.py +++ b/wikstraktor_server.py @@ -22,10 +22,21 @@ def search(wiktlang, wordlang, word): if w.fetch(word) > 0: resp = w.__str__() status = 200 + mimetype='application/json' else: - resp = f"{word} is unknown" + resp = f"""<!doctype html> +<html> + <head> + <title>Error</title> + </head> + <body> + <h1>{word}</h1> + <p>{word} is unknown in “{wordlang}†in {wiktlang}.wiktionary.org.</p> + </body> +</html>""" status = 404 - return Response(resp, status=status) + mimetype='text/html' + return Response(resp, status=status, mimetype=mimetype) if __name__ == "__main__": app.run(host=config.host, port=config.port, debug=config.debugging)