Update nft svc
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Andrey Gumirov
2022-05-03 11:04:21 +07:00
parent 0649bb445c
commit db629bb804
2 changed files with 9 additions and 5 deletions

View File

@ -1,11 +1,13 @@
import base64
import io
import random
from PIL import Image
from flask import Flask, request, jsonify
import matplotlib.image as mpimg
import numpy as np
import numba
import pickle
import base64
app = Flask(__name__)
@ -43,12 +45,14 @@ def get_encoded_img(arr):
@app.route('/getImage', methods=['GET'])
def get_image():
name = request.args.get('name')
fractal = optimized_mandelbrot(1000, 1000, np.random.randint(2, 251), np.random.uniform(-1, 1), np.random.uniform(-1, 1))
img = get_encoded_img(fractal)
with open('data_100.pickle', 'rb') as f:
images = pickle.load(f)
buffered = io.BytesIO()
random.choice(images).save(buffered, format="JPEG")
img_str = base64.b64encode(buffered.getvalue())
return jsonify({
"code": 0,
"image": img,
"image": str(img_str),
"first_time": 1
})