Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -52,13 +52,19 @@ def preprocess_and_create_stylecloud(file_path, output_name='stylecloud.png',
|
|
52 |
plt.show()
|
53 |
|
54 |
def create_stylecloud(text, language, icon):
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
62 |
|
63 |
st.title("WordCloud Creator")
|
64 |
|
@@ -105,7 +111,7 @@ if file is not None:
|
|
105 |
</a>
|
106 |
""",
|
107 |
unsafe_allow_html=True
|
108 |
-
|
109 |
|
110 |
image = Image.open("static/stylecloud.png")
|
111 |
st.image(image, caption='WordCloud', use_column_width=True)
|
|
|
52 |
plt.show()
|
53 |
|
54 |
def create_stylecloud(text, language, icon):
|
55 |
+
output_filename = "stylecloud.png"
|
56 |
+
static_dir = os.path.join(os.path.dirname(os.path.abspath(__file__)), "static")
|
57 |
+
os.makedirs(static_dir, exist_ok=True)
|
58 |
+
output_file = os.path.join(static_dir, output_filename)
|
59 |
+
|
60 |
+
stylecloud.gen_stylecloud(text=text, icon_name=icon, output_name=output_file)
|
61 |
+
|
62 |
+
# Dosyayı Base64 olarak kodla
|
63 |
+
with open(output_file, "rb") as file:
|
64 |
+
data = file.read()
|
65 |
+
encoded = base64.b64encode(data).decode()
|
66 |
+
|
67 |
+
return encoded
|
68 |
|
69 |
st.title("WordCloud Creator")
|
70 |
|
|
|
111 |
</a>
|
112 |
""",
|
113 |
unsafe_allow_html=True
|
114 |
+
)
|
115 |
|
116 |
image = Image.open("static/stylecloud.png")
|
117 |
st.image(image, caption='WordCloud', use_column_width=True)
|