-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCreate HTML post.py
More file actions
63 lines (60 loc) · 2.75 KB
/
Create HTML post.py
File metadata and controls
63 lines (60 loc) · 2.75 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#HTML post creator for any website
#Add you post page website code after the 'DOCTYPE' section. Mind the tags for page title, paragrapf etc.
import textwrap
def generate_html():
html_content = ""
while True:
print("##### Καλωσήρθες στο δημιουργό άρθρων της ιστοσελίδας της Antisel \nΕπίλεξε ένα HTML element για να προσθέσεις στο post σου (ή δώσε 'OK' για ολοκλήρωση):\n")
print("1. Τίτλος άρθρου")
print("2. Παράγραφος")
print("3. Εικόνα")
print("4. Αριθμημένη λίστα")
print("5. Bullet λίστα")
user_input = input("\nΔώσε την επιλογή σου: ")
if user_input == "OK":
break
elif user_input == "1":
title_text = input("Πρόσθεσε τίτλο: ")
html_content += f"<h1>{title_text}</h1>"
elif user_input == "2":
paragraph_text = input("Πρόσθεσε παράγραφο: ")
html_content += f"<p>{paragraph_text}</p>"
elif user_input == "3":
image_url = input("Enter image URL: ")
alt_text = input("Enter alternate text: ")
html_content += f"<img src='{image_url}' alt='{alt_text}'/>\n"
elif user_input == "4":
html_content += "<ol>"
while True:
list_item = input("Πρόθεσε αντικείμενο λίστας (ή δώσε 'done' για ολοκλήρωση): ")
if list_item == "done":
html_content += "</ol>"
break
else:
html_content += f"<li>{list_item}</li>"
elif user_input == "5":
html_content += "<ul>\n"
while True:
list_item = input("Πρόθεσε αντικείμενο λίστας (ή δώσε 'done' για ολοκλήρωση): ")
if list_item == "done":
html_content += "</ul>\n"
break
else:
html_content += f" <li>{list_item}</li>\n"
else:
print("Λάθος επιλογή. Παρακαλώ δοκίμασε ξανά.")
file_name = input("Δώσε όνομα αρχείου (π.χ. index.html): ")
with open(file_name, "w") as f:
f.write(textwrap.dedent(f"""
<!DOCTYPE html>
<html>
<head>
<title>{file_name}</title>
</head>
<body>
{html_content}
</body>
</html>
"""))
print(f"File saved as {file_name}")
generate_html()