File size: 418 Bytes
95877f1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
from flask import Flask, request, send_file
from model import load_model, generate
from io import BytesIO

app = Flask(__name__)
model = load_model()

def serve_img(pilImage):
  imageIO = BytesIO()
  pilImage.save(imageIO, 'JPEG', quality=70)
  imageIO.seek(0)
  return imageIO


@app.route("/",methods=['GET'])
def index():
  image = generate(model)
  g = serve_img(image)
  return send_file(g, mimetype="image/jpeg")