from datetime import datetime import click # Used to write post content, it launches a text editor to type into # Other python files # import create_pages import config import rebuild try: import posts except: print("No posts database") try: import users except: print("No users database") import output def newpost(userID, username, datetime): title = input("Title: ") content = click.edit() content = content.replace("'", "\'") output.log(content) datetime = datetime.now().strftime("%d%m%YZ%H%M%ST") posts.posts.append({'userID': userID, 'title': title, 'content': content, 'pubdate': datetime, 'editdate': datetime}) with open("posts.py", "w") as posts_file: posts_file.write(f"posts = {posts.posts}") rebuild.rebuild()