Added config.ini

This commit is contained in:
root 2023-06-02 10:24:06 +02:00
parent 9406e1fc50
commit 9d13903b6b
4 changed files with 708 additions and 699 deletions

View File

@ -6,7 +6,7 @@ Simple choice game.
1. Clone the Repo into `/opt/ab/`
2. Put A/B questions in `ab.txt`
3. Optional: Set `title` and `separator` variables in `game.py`
3. Optional: Set config variables in `config.ini`
4. Install requirements (pip install -r requirements.txt)
5. Install `supervisord`
6. Copy `supervisor.conf` to `/etc/supervisor/conf.d/abgame.conf`

1388
ab.txt

File diff suppressed because it is too large Load Diff

4
config.ini Normal file
View File

@ -0,0 +1,4 @@
[main]
title = A oder B
separator = oder
separator_char = ;

13
game.py
View File

@ -2,21 +2,26 @@
from random import choice
from flask import Flask, render_template
from configparser import ConfigParser
app = Flask(__name__,
static_url_path='',
static_folder='static',
template_folder='templates')
config = ConfigParser()
config.read('config.ini')
@app.route("/")
def hello():
title = 'A oder B'
separator = ' oder '
title = config.get('main', 'title')
separator = config.get('main', 'separator')
separator_char = config.get('main', 'separator_char')
ablines = []
lines = getContent()
for line in lines:
ab = line.split(separator)
ab = line.split(separator_char)
ablines.append(
{'A': str(ab[0]), 'B': str(ab[1])}
)