toki_pona/web/app.py

37 lines
699 B
Python
Raw Normal View History

2024-04-10 07:27:09 +02:00
from flask import Flask, render_template, request
app = Flask(__name__)
WORD_LI = 'li'
PARTICLES = ['en', WORD_LI, 'e', 'la', 'pi', 'o', 'anu']
EMOTICLE = ['a']
PRONOUNS = ['mi', 'sina', 'ona', 'ni']
PREPOSITIONS = ['lon', 'tawa', 'tan', 'sama', 'kepeken']
PREVERBS = ['wile', 'sona', 'awen', 'kama', 'ken', 'lukin']
QUESTIONS = ['seme']
def create_context(sentence):
words = sentence.split()
@app.route('/', methods=['GET', 'POST'])
def home():
ctx = {}
if request.method == 'POST':
sentence = request.form.get('sentence')
ctx = create_context(sentence)
return render_template('home.html', ctx=ctx)
if __name__ == '__main__':
app.run(debug=True)