feat: Auto-5vor8 Routes (/auto5vor8, toggle, settings)
This commit is contained in:
parent
ad40d28c38
commit
5237ff6d20
1 changed files with 46 additions and 0 deletions
|
|
@ -533,6 +533,52 @@ def api_skip(date_str):
|
|||
return jsonify({'success': True})
|
||||
|
||||
|
||||
# ── Auto-5vor8 ────────────────────────────────────────────────────────────────
|
||||
|
||||
def _get_auto5vor8_settings():
|
||||
conn = db.get_conn()
|
||||
rows = conn.execute("SELECT key, value FROM auto_5vor8_settings").fetchall()
|
||||
conn.close()
|
||||
return {r["key"]: r["value"] for r in rows}
|
||||
|
||||
|
||||
def _set_auto5vor8_setting(key, value):
|
||||
conn = db.get_conn()
|
||||
conn.execute(
|
||||
"INSERT INTO auto_5vor8_settings (key, value) VALUES (?, ?) "
|
||||
"ON CONFLICT(key) DO UPDATE SET value=excluded.value",
|
||||
(key, str(value))
|
||||
)
|
||||
conn.commit()
|
||||
conn.close()
|
||||
|
||||
|
||||
@app.route('/auto5vor8')
|
||||
def auto5vor8():
|
||||
settings = _get_auto5vor8_settings()
|
||||
return render_template('auto5vor8.html', settings=settings)
|
||||
|
||||
|
||||
@app.route('/auto5vor8/toggle', methods=['POST'])
|
||||
def auto5vor8_toggle():
|
||||
current = _get_auto5vor8_settings()
|
||||
new_val = '0' if current.get('enabled') == '1' else '1'
|
||||
_set_auto5vor8_setting('enabled', new_val)
|
||||
state = 'aktiviert' if new_val == '1' else 'deaktiviert'
|
||||
logger.info('Auto-5vor8 %s', state)
|
||||
return redirect(url_for('auto5vor8'))
|
||||
|
||||
|
||||
@app.route('/auto5vor8/settings', methods=['POST'])
|
||||
def auto5vor8_save_settings():
|
||||
for field in ('prompt', 'post_time', 'ai_model', 'feed_id', 'tag'):
|
||||
val = request.form.get(field)
|
||||
if val is not None:
|
||||
_set_auto5vor8_setting(field, val.strip())
|
||||
logger.info('Auto-5vor8 Einstellungen gespeichert')
|
||||
return redirect(url_for('auto5vor8'))
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
db.init_db()
|
||||
app.run(host='0.0.0.0', port=8080, debug=False)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue