32 lines
No EOL
841 B
Python
32 lines
No EOL
841 B
Python
from flask import Flask, render_template, send_from_directory
|
|
import rfc2229
|
|
import configparser
|
|
|
|
# Load configuration
|
|
config = configparser.ConfigParser()
|
|
config.read('config.ini')
|
|
server = config['server']['host']
|
|
port = config['server']['port']
|
|
|
|
app = Flask(__name__)
|
|
|
|
@app.route('/')
|
|
def home():
|
|
return render_template('index.j2', server="everypizza.im dictd 1.13.3/rf on Linux 6.13.7-arch1-1")
|
|
|
|
@app.route('/define/<word>')
|
|
def define(word):
|
|
client = rfc2229.RFC2229Client()
|
|
client.connect(server, port)
|
|
definition = client.define(word)
|
|
client.quit()
|
|
return render_template('define.j2', word=word, definition=definition)
|
|
|
|
@app.route('/style.css')
|
|
def style():
|
|
return send_from_directory('static', 'output.css')
|
|
|
|
print(rfc2229._read_response)
|
|
|
|
if __name__ == '__main__':
|
|
app.run(host="0.0.0.0", port=8080) |