Files
blog/app/__init__.py
2026-03-05 01:53:19 -06:00

30 lines
1.1 KiB
Python

from flask import Flask
from app import build
from pathlib import Path
import markdown
import os
from dotenv import load_dotenv
app = Flask(__name__)
PRIVATE_VAULT_DIR = Path("/vault")
PUBLIC_VAULT_DIR = "/content"
build.obsidian_vault(PRIVATE_VAULT_DIR) # initialize the private obsidian repo
build.public_vault(PRIVATE_VAULT_DIR, PUBLIC_VAULT_DIR) # initialize the public notes from the private repo
@app.route("/")
def index():
md_content = "# Welcome to my blog!\nThis is rendered from **Markdown**.\n##[test](http://localhost/test)"
html_content = markdown.markdown(md_content)
return html_content
@app.route("/api/vault-update", methods='POST') #webhook for vault updated
def update_vault():
# TODO SECURE THIS WITH SECRETTTTT or auth header
build.obsidian_vault(PRIVATE_VAULT_DIR) # initialize the private obsidian repo
build.public_vault(PRIVATE_VAULT_DIR, PUBLIC_VAULT_DIR)# initialize the public notes from the private repo
return "vault-rebuilt"
@app.route ("/<filename>") # renders a filename if not otherwise specified
def render_post(filename):
return build.html_file(filename, PUBLIC_VAULT_DIR)