diff --git a/Dockerfile b/Dockerfile index b5fe72c..2a504ce 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,7 +2,8 @@ FROM python:3.12-slim WORKDIR /app -COPY app.py /app/app.py +#COPY app.py /app/app.py +COPY . . RUN pip install flask diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..2070392 --- /dev/null +++ b/Makefile @@ -0,0 +1,4 @@ +default: + podman build -t fastionary . + podman stop fast || echo + podman run --name fast --rm -d -p 8080:5000 fastionary diff --git a/README.md b/README.md index a7ab092..fe3e07b 100644 --- a/README.md +++ b/README.md @@ -11,5 +11,5 @@ Fastionary is an alternative front-end for wiktionary data. git clone https://git.wlankabel.at/onipa/fastionary.git cd fastionary docker build -t fastionary . -docker run --rm -p 5000:5000 -d fastionary +docker run --rm -d -p 5000:5000 fastionary ``` diff --git a/app.py b/app.py index bf8c4bb..fbf8833 100644 --- a/app.py +++ b/app.py @@ -1,10 +1,21 @@ from flask import Flask +from flask import request +from flask import render_template app = Flask(__name__) -@app.route("/") -def hello_world(): - return "
Hello, World!
" +def get_translations(word): + dictionary={'yes':'oui', 'no':'non', 'cheese':'fromage', 'yesterday':'hier', 'tomorrow':'demain', 'yes man':'jasager'} + translation = None + if word != None or word != '': + translation = dictionary.get(word) + return translation + +@app.route('/') +def trans(q=None): + query = request.args.get('q', None) + translation = get_translations(query) + return render_template('trans.html', q=query, t=translation) if __name__ == "__main__": app.run(host="0.0.0.0", port=5000, debug=True) diff --git a/templates/trans.html b/templates/trans.html new file mode 100644 index 0000000..7096c66 --- /dev/null +++ b/templates/trans.html @@ -0,0 +1,35 @@ + + + + + +| {{ q }} | +{{ t }} | +