This commit is contained in:
@ -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
|
||||
})
|
||||
|
||||
|
BIN
nft_svc/data_100.pickle
Normal file
BIN
nft_svc/data_100.pickle
Normal file
Binary file not shown.
Reference in New Issue
Block a user