prove of concept

This commit is contained in:
oni@bor 2026-01-05 13:56:01 +01:00
parent 731e2c263f
commit fd2fd96e96
6 changed files with 84 additions and 5 deletions

View File

@ -2,7 +2,8 @@ FROM python:3.12-slim
WORKDIR /app WORKDIR /app
COPY app.py /app/app.py #COPY app.py /app/app.py
COPY . .
RUN pip install flask RUN pip install flask

4
Makefile Normal file
View File

@ -0,0 +1,4 @@
default:
podman build -t fastionary .
podman stop fast || echo
podman run --name fast --rm -d -p 8080:5000 fastionary

View File

@ -11,5 +11,5 @@ Fastionary is an alternative front-end for wiktionary data.
git clone https://git.wlankabel.at/onipa/fastionary.git git clone https://git.wlankabel.at/onipa/fastionary.git
cd fastionary cd fastionary
docker build -t fastionary . docker build -t fastionary .
docker run --rm -p 5000:5000 -d fastionary docker run --rm -d -p 5000:5000 fastionary
``` ```

17
app.py
View File

@ -1,10 +1,21 @@
from flask import Flask from flask import Flask
from flask import request
from flask import render_template
app = Flask(__name__) app = Flask(__name__)
@app.route("/") def get_translations(word):
def hello_world(): dictionary={'yes':'oui', 'no':'non', 'cheese':'fromage', 'yesterday':'hier', 'tomorrow':'demain', 'yes man':'jasager'}
return "<p>Hello, World!</p>" 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__": if __name__ == "__main__":
app.run(host="0.0.0.0", port=5000, debug=True) app.run(host="0.0.0.0", port=5000, debug=True)

35
templates/trans.html Normal file
View File

@ -0,0 +1,35 @@
<!doctype html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<title>Fastionary</title>
</head>
<body>
<h1>Fastionary</h1>
<form action="" method="get">
<label for="searchQuery">Translate:</label>
<input type="text" id="searchQuery" name="q">
<button type="submit">Search</button>
</form>
<br>
<!--
{% if q %}
<h1>Your searched for: "{{ q }}"</h1>
<h1>Result: "{{ t }}"!</h1>
{% endif %}
-->
{% if t %}
<table border="1">
<tr>
<td>{{ q }}</td>
<td>{{ t }}</td>
</tr>
</table>
{% endif %}
</body>
</html>

28
todo.md Normal file
View File

@ -0,0 +1,28 @@
# Milestones
## v0.0.1
- [ ] pytest:
- [ ] translation module
- [ ] https://flask.palletsprojects.com/en/stable/tutorial/tests/
- [x] return a translation of a word
- [ ] use json file as database
- [ ] define api
- [ ] from
- [ ] to
- [ ] word
- [ ] refine translation
- [ ] output more than one results
- [ ] cut away leading spaces
- [ ] fuzzy find asem - asɛm
## v0.0.2
- [ ] use database sqlite? mongodb?
- [ ] https://flask.palletsprojects.com/en/stable/tutorial/database/
- [ ] css
## v0.0.3
- [ ] make project installable
- [ ] https://flask.palletsprojects.com/en/stable/tutorial/install/
## v0.0.4
- [ ] deploy
- [ ] https://flask.palletsprojects.com/en/stable/tutorial/deploy/