2023-06-02 09:48:48 +02:00
|
|
|
#! /bin/python3
|
|
|
|
|
|
|
|
from random import choice
|
2023-06-02 10:11:06 +02:00
|
|
|
from flask import Flask, render_template
|
2023-06-02 10:24:06 +02:00
|
|
|
from configparser import ConfigParser
|
|
|
|
|
2023-06-02 09:48:48 +02:00
|
|
|
app = Flask(__name__,
|
|
|
|
static_url_path='',
|
|
|
|
static_folder='static',
|
|
|
|
template_folder='templates')
|
|
|
|
|
2023-06-02 10:24:06 +02:00
|
|
|
config = ConfigParser()
|
|
|
|
config.read('config.ini')
|
|
|
|
|
2023-06-02 09:48:48 +02:00
|
|
|
@app.route("/")
|
|
|
|
def hello():
|
2023-06-02 10:24:06 +02:00
|
|
|
title = config.get('main', 'title')
|
|
|
|
separator = config.get('main', 'separator')
|
|
|
|
separator_char = config.get('main', 'separator_char')
|
2023-06-02 10:11:06 +02:00
|
|
|
ablines = []
|
2023-06-02 09:48:48 +02:00
|
|
|
|
|
|
|
lines = getContent()
|
|
|
|
for line in lines:
|
2023-06-02 10:24:06 +02:00
|
|
|
ab = line.split(separator_char)
|
2023-06-02 10:11:06 +02:00
|
|
|
ablines.append(
|
|
|
|
{'A': str(ab[0]), 'B': str(ab[1])}
|
|
|
|
)
|
2023-06-02 09:48:48 +02:00
|
|
|
|
2023-06-02 10:11:06 +02:00
|
|
|
return render_template('index.html', title=title, separator=separator, content=ablines)
|
2023-06-02 09:48:48 +02:00
|
|
|
|
|
|
|
def getContent():
|
|
|
|
lines = [a.strip() for a in open("ab.txt").readlines()]
|
|
|
|
result = [choice(lines) for a in range(5)]
|
|
|
|
|
|
|
|
return result
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
from waitress import serve
|
|
|
|
serve(app, host='0.0.0.0', port=5000, ident='a/b game')
|