File size: 950 Bytes
19c33ef |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
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 = """
# <html>
# <body>
# <h1>Generated Image</h1>
# <img src="data:image/jpeg;base64,{{ image }}" />
# </body>
# </html>
# """
# 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)
|