Uploads to the website but uses "Unknown Prompt" for now.
This commit is contained in:
parent
399a979826
commit
16cd44bb41
1 changed files with 27 additions and 21 deletions
|
|
@ -75,26 +75,31 @@ async def handle_error(error):
|
||||||
return error
|
return error
|
||||||
|
|
||||||
|
|
||||||
async def upload_ftp_ai_images(filename, prompt):
|
async def upload_ftp_ai_images(folder):
|
||||||
html_file = "phixxy.com/ai-images/index.html"
|
for filename in os.listdir(folder):
|
||||||
html_insert = '''<!--REPLACE THIS COMMENT-->
|
if filename[-4:] == '.png':
|
||||||
<div>
|
filepath = folder + filename
|
||||||
<img src="<!--filename-->" loading="lazy">
|
prompt = "Unknown Prompt" # Will have to update this later
|
||||||
<p class="image-description"><!--description--></p>
|
|
||||||
</div>'''
|
html_file = "phixxy.com/ai-images/index.html"
|
||||||
img_list = []
|
html_insert = '''<!--REPLACE THIS COMMENT-->
|
||||||
server_folder = (os.getenv('ftp_public_html') + 'ai-images/')
|
<div>
|
||||||
new_filename = str(time.time_ns()) + ".png"
|
<img src="<!--filename-->" loading="lazy">
|
||||||
await upload_sftp(filename, server_folder, new_filename)
|
<p class="image-description"><!--description--></p>
|
||||||
print("Uploaded", new_filename)
|
</div>'''
|
||||||
with open(html_file, 'r') as f:
|
server_folder = (os.getenv('ftp_public_html') + 'ai-images/')
|
||||||
html_data = f.read()
|
new_filename = str(time.time_ns()) + ".png"
|
||||||
html_insert = html_insert.replace("<!--filename-->", new_filename)
|
await upload_sftp(filepath, server_folder, new_filename)
|
||||||
html_insert = html_insert.replace("<!--description-->", prompt)
|
print("Uploaded", new_filename)
|
||||||
html_data = html_data.replace("<!--REPLACE THIS COMMENT-->", html_insert)
|
with open(html_file, 'r') as f:
|
||||||
with open(html_file, "w") as f:
|
html_data = f.read()
|
||||||
f.writelines(html_data)
|
html_insert = html_insert.replace("<!--filename-->", new_filename)
|
||||||
await upload_sftp(html_file, server_folder, "index.html")
|
html_insert = html_insert.replace("<!--description-->", prompt)
|
||||||
|
html_data = html_data.replace("<!--REPLACE THIS COMMENT-->", html_insert)
|
||||||
|
with open(html_file, "w") as f:
|
||||||
|
f.writelines(html_data)
|
||||||
|
await upload_sftp(html_file, server_folder, "index.html")
|
||||||
|
os.rename(filepath, f"tmp/{new_filename}")
|
||||||
|
|
||||||
def create_channel_config(filepath):
|
def create_channel_config(filepath):
|
||||||
config_dict = {
|
config_dict = {
|
||||||
|
|
@ -275,6 +280,7 @@ async def task_loop():
|
||||||
#Run every minute
|
#Run every minute
|
||||||
if current_time.tm_sec == 0:
|
if current_time.tm_sec == 0:
|
||||||
await meme_handler('tmp/meme/')
|
await meme_handler('tmp/meme/')
|
||||||
|
await upload_ftp_ai_images('tmp/sfw')
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue