Added config.ini
This commit is contained in:
parent
9406e1fc50
commit
9d13903b6b
|
@ -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`
|
||||
|
|
|
@ -0,0 +1,4 @@
|
|||
[main]
|
||||
title = A oder B
|
||||
separator = oder
|
||||
separator_char = ;
|
13
game.py
13
game.py
|
@ -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])}
|
||||
)
|
||||
|
|
Loading…
Reference in New Issue