mirror of
https://github.com/karl0ss/ai_image_frame_server.git
synced 2025-04-28 11:13:41 +01:00
user config controls reload interval
This commit is contained in:
parent
4fd857c12f
commit
8064c90be9
@ -1,6 +1,8 @@
|
|||||||
from flask import Flask, render_template, send_from_directory, redirect, url_for
|
from flask import Flask, render_template, send_from_directory, redirect, url_for
|
||||||
import os
|
import os
|
||||||
from lib import create_image
|
from lib import create_image, load_config
|
||||||
|
|
||||||
|
user_config = load_config()
|
||||||
|
|
||||||
app = Flask(__name__)
|
app = Flask(__name__)
|
||||||
|
|
||||||
@ -9,7 +11,7 @@ image_folder = "./output"
|
|||||||
@app.route('/')
|
@app.route('/')
|
||||||
def index():
|
def index():
|
||||||
# latest_image = get_latest_image()
|
# latest_image = get_latest_image()
|
||||||
return render_template("index.html", image="./image.png")
|
return render_template("index.html", image="./image.png", reload_interval=user_config["frame"]["reload_interval"])
|
||||||
|
|
||||||
@app.route('/images/<filename>')
|
@app.route('/images/<filename>')
|
||||||
def images(filename):
|
def images(filename):
|
||||||
@ -23,5 +25,5 @@ def create():
|
|||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
os.makedirs(image_folder, exist_ok=True) # Ensure the folder exists
|
os.makedirs(image_folder, exist_ok=True) # Ensure the folder exists
|
||||||
app.run(host="0.0.0.0", port=5000, debug=True)
|
app.run(host="0.0.0.0", port=user_config["frame"]["port"], debug=True)
|
||||||
|
|
||||||
|
8
lib.py
8
lib.py
@ -8,16 +8,16 @@ import os
|
|||||||
|
|
||||||
from comfy_api_simplified import ComfyApiWrapper, ComfyWorkflowWrapper
|
from comfy_api_simplified import ComfyApiWrapper, ComfyWorkflowWrapper
|
||||||
|
|
||||||
|
def load_config():
|
||||||
user_config = configparser.ConfigParser()
|
user_config = configparser.ConfigParser()
|
||||||
try:
|
try:
|
||||||
user_config.read("./user_config.cfg")
|
user_config.read("./user_config.cfg")
|
||||||
output_folder = user_config["comfyui"]["output_dir"]
|
|
||||||
logging.debug("Configuration loaded successfully.")
|
logging.debug("Configuration loaded successfully.")
|
||||||
|
return user_config
|
||||||
except KeyError as e:
|
except KeyError as e:
|
||||||
logging.error(f"Missing configuration key: {e}")
|
logging.error(f"Missing configuration key: {e}")
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
|
|
||||||
def rename_image():
|
def rename_image():
|
||||||
"""Rename 'image.png' to a timestamped filename if it exists in the output folder."""
|
"""Rename 'image.png' to a timestamped filename if it exists in the output folder."""
|
||||||
old_path = os.path.join(user_config["comfyui"]["output_dir"], "image.png")
|
old_path = os.path.join(user_config["comfyui"]["output_dir"], "image.png")
|
||||||
@ -84,3 +84,7 @@ def create_image():
|
|||||||
prompt = send_prompt_to_openwebui(user_config["comfyui"]["prompt"])
|
prompt = send_prompt_to_openwebui(user_config["comfyui"]["prompt"])
|
||||||
print(f"Generated prompt: {prompt}")
|
print(f"Generated prompt: {prompt}")
|
||||||
generate_image("image", prompt)
|
generate_image("image", prompt)
|
||||||
|
|
||||||
|
|
||||||
|
user_config = load_config()
|
||||||
|
output_folder = user_config["comfyui"]["output_dir"]
|
||||||
|
@ -26,7 +26,7 @@
|
|||||||
<script>
|
<script>
|
||||||
setInterval(() => {
|
setInterval(() => {
|
||||||
location.reload();
|
location.reload();
|
||||||
}, 30000); // Refresh every 5 seconds
|
}, {{ reload_interval }}); // Refresh every 5 seconds
|
||||||
</script>
|
</script>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
@ -1,3 +1,7 @@
|
|||||||
|
[frame]
|
||||||
|
reload_interval = 30000
|
||||||
|
port = 5000
|
||||||
|
|
||||||
[comfyui]
|
[comfyui]
|
||||||
comfyui_url = http://comfyui
|
comfyui_url = http://comfyui
|
||||||
model = zavychromaxl_v100.safetensors
|
model = zavychromaxl_v100.safetensors
|
||||||
|
Loading…
x
Reference in New Issue
Block a user