from flask import Flask, request, jsonify, render_template_string
from model import generate_image
app = Flask(__name__)
# @app.route("/")
# def api_generate_image():
# # Generate the image using the model
# image = generate_image("Hello, world!")
# # Embed the image in an HTML page
# html = """
#
#
# Generated Image
#
#
#
# """
# return render_template_string(html, image=image)
@app.route("/generate_image", methods=["POST"])
def api_generate_image():
# Get the input text from the request
text = request.json["text"]
# Generate the image using the model
image = generate_image(text)
# Return the generated image as the response
response = {"image": image}
return jsonify(response)
if __name__ == "__main__":
app.run(host="0.0.0.0", port=5000)