test static gen

thumb
km0 2 years ago
parent c19071f117
commit 23dacbcbc2

@ -46,28 +46,8 @@ def get_md_contents(filename, directory='./contents'):
return metadata, html_content return metadata, html_content
# FLASK APP def render_home():
base_url = "~kamo" with open('render.html', 'r+w') as f:
projects = 'projects'
# create flask application
app = Flask(__name__,
static_url_path=f'/soupboat/{base_url}/static',
static_folder=f'/soupboat/{base_url}/static')
# Markdown(app, extensions=['extra'])
# app.jinja_env.extend(jinja2_highlight_cssclass = 'codehilite')
# add the base_url variable to all the flask templates
@app.context_processor
def set_base_url():
return dict(base_url=base_url)
# Homepage
@app.route(f"/{base_url}/")
def home_page():
# get the basic info of the website from the /contents/home.md file # get the basic info of the website from the /contents/home.md file
meta, content = get_md_contents("home.md") meta, content = get_md_contents("home.md")
projects_list = [] projects_list = []
@ -90,7 +70,30 @@ def home_page():
"content": content, "content": content,
"projects": projects_list "projects": projects_list
} }
return render_template("home.html", **home) f.write(render_template("home.html", **home))
# FLASK APP
base_url = "~kamo"
projects = 'projects'
# create flask application
app = Flask(__name__,
static_url_path=f'/soupboat/{base_url}/static',
static_folder=f'/soupboat/{base_url}/static')
# Markdown(app, extensions=['extra'])
# app.jinja_env.extend(jinja2_highlight_cssclass = 'codehilite')
# add the base_url variable to all the flask templates
@app.context_processor
def set_base_url():
return dict(base_url=base_url)
# Homepage
@app.route(f"/{base_url}/")
def home_page():
return send_from_directory(f'{app.root_path}/render.html')
# For generic pages we can include a common template and change only the contents # For generic pages we can include a common template and change only the contents
@ -123,7 +126,12 @@ def sendStaticFiles(project, filename):
def pull(): def pull():
if request.method == 'POST': if request.method == 'POST':
subprocess.call(['sh', '/home/kamo/public_html/update.sh']) subprocess.call(['sh', '/home/kamo/public_html/update.sh'])
print(request.form['payload'])
with open('log.txt', 'a') as f:
f.write(request.form['payload'])
render_home()
return 'Updated' return 'Updated'
return 'GET method not supported' return 'GET method not supported'

Loading…
Cancel
Save