Update app.py
Browse files
app.py
CHANGED
@@ -43,14 +43,24 @@ def get_protein_image(pdbview):
|
|
43 |
pdbview.render()
|
44 |
png = pdbview.pngImage()
|
45 |
|
46 |
-
|
47 |
-
|
48 |
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
54 |
|
55 |
return base64.b64encode(png_bytes).decode('utf-8')
|
56 |
|
|
|
43 |
pdbview.render()
|
44 |
png = pdbview.pngImage()
|
45 |
|
46 |
+
print(f"Type of png: {type(png)}")
|
47 |
+
print(f"Dir of png: {dir(png)}")
|
48 |
|
49 |
+
if hasattr(png, 'shape'):
|
50 |
+
print(f"Shape of png: {png.shape}")
|
51 |
+
|
52 |
+
if hasattr(png, 'dtype'):
|
53 |
+
print(f"Dtype of png: {png.dtype}")
|
54 |
+
|
55 |
+
# Try to convert to bytes
|
56 |
+
if isinstance(png, (bytes, bytearray)):
|
57 |
+
png_bytes = png
|
58 |
+
elif hasattr(png, 'tobytes'):
|
59 |
+
png_bytes = png.tobytes()
|
60 |
+
elif hasattr(png, 'tostring'):
|
61 |
+
png_bytes = png.tostring()
|
62 |
+
else:
|
63 |
+
raise TypeError(f"Unable to convert {type(png)} to bytes")
|
64 |
|
65 |
return base64.b64encode(png_bytes).decode('utf-8')
|
66 |
|