mirror of
https://github.com/karl0ss/ai_image_frame_server.git
synced 2025-06-08 19:35:07 +01:00
fix the double generation
This commit is contained in:
parent
4b62b5cd07
commit
55ccd71383
@ -4,6 +4,8 @@ from flask import (
|
|||||||
send_from_directory,
|
send_from_directory,
|
||||||
request,
|
request,
|
||||||
jsonify,
|
jsonify,
|
||||||
|
redirect,
|
||||||
|
url_for
|
||||||
)
|
)
|
||||||
import os
|
import os
|
||||||
import time
|
import time
|
||||||
@ -92,26 +94,28 @@ def cancel_job() -> None:
|
|||||||
|
|
||||||
|
|
||||||
@app.route("/create", methods=["GET", "POST"])
|
@app.route("/create", methods=["GET", "POST"])
|
||||||
def create() -> str:
|
def create():
|
||||||
"""Handles image creation requests.
|
if request.method == "POST":
|
||||||
Args:
|
prompt = request.form.get("prompt")
|
||||||
None
|
model = request.form.get("model", "Random")
|
||||||
Returns:
|
|
||||||
str: Redirect to the main page or a JSON response.
|
if not prompt:
|
||||||
"""
|
prompt = create_prompt_on_openwebui(user_config["comfyui"]["prompt"])
|
||||||
prompt = request.form.get("prompt") if request.method == "POST" else None
|
|
||||||
model = request.form.get("model") if request.method == "POST" else "Random"
|
# Start generation in background
|
||||||
|
threading.Thread(target=lambda: create_image(prompt, model)).start()
|
||||||
|
|
||||||
|
# store prompt in query string temporarily
|
||||||
|
return redirect(url_for("image_queued", prompt=prompt))
|
||||||
|
|
||||||
|
# For GET requests, just show the form to enter prompt
|
||||||
|
return render_template("create_image.html", models=load_models_from_config())
|
||||||
|
|
||||||
|
|
||||||
if prompt is None:
|
@app.route("/image_queued")
|
||||||
prompt = create_prompt_on_openwebui(user_config["comfyui"]["prompt"])
|
def image_queued():
|
||||||
|
prompt = request.args.get("prompt", "No prompt provided.")
|
||||||
def create_image_in_background():
|
return render_template("image_queued.html", prompt=prompt)
|
||||||
create_image(prompt, model)
|
|
||||||
|
|
||||||
threading.Thread(target=create_image_in_background).start()
|
|
||||||
return render_template('image_queued.html', prompt=prompt)
|
|
||||||
|
|
||||||
|
|
||||||
def scheduled_task() -> None:
|
def scheduled_task() -> None:
|
||||||
"""Executes the scheduled image generation task."""
|
"""Executes the scheduled image generation task."""
|
||||||
|
Loading…
x
Reference in New Issue
Block a user