|
|
|
@ -3,6 +3,7 @@ import os
|
|
|
|
|
|
|
|
|
|
from flask import Flask, render_template, request, url_for, redirect, jsonify, abort, send_from_directory
|
|
|
|
|
import markdown
|
|
|
|
|
import subprocess
|
|
|
|
|
import frontmatter
|
|
|
|
|
from datetime import datetime
|
|
|
|
|
import json
|
|
|
|
@ -40,7 +41,8 @@ def get_md_contents(filename, directory='./contents'):
|
|
|
|
|
''' Return contents from a filename as frontmatter handler '''
|
|
|
|
|
with open(f"{directory}/{filename}", "r") as f:
|
|
|
|
|
metadata, content = frontmatter.parse(f.read())
|
|
|
|
|
html_content = markdown.markdown(content, extensions=['markdown.extensions.attr_list','markdown.extensions.codehilite','markdown.extensions.fenced_code'])
|
|
|
|
|
html_content = markdown.markdown(content, extensions=[
|
|
|
|
|
'markdown.extensions.attr_list', 'markdown.extensions.codehilite', 'markdown.extensions.fenced_code'])
|
|
|
|
|
return metadata, html_content
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -112,8 +114,6 @@ def p_info(project=None):
|
|
|
|
|
return render_template(template, **meta, content=content)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@app.route(f'/{base_url}/projects/<project>/<path:filename>')
|
|
|
|
|
def sendStaticFiles(project, filename):
|
|
|
|
|
return send_from_directory(app.root_path + f'/projects/{project}/', filename, conditional=True)
|
|
|
|
@ -122,11 +122,11 @@ def sendStaticFiles(project, filename):
|
|
|
|
|
@app.route(f'/{base_url}/hook/', methods=['GET', 'POST'])
|
|
|
|
|
def pull():
|
|
|
|
|
if request.method == 'POST':
|
|
|
|
|
import subprocess
|
|
|
|
|
output = subprocess.call(['sh', '/home/kamo/public_html/update.sh'])
|
|
|
|
|
print(output)
|
|
|
|
|
return output
|
|
|
|
|
subprocess.call(['sh', '/home/kamo/public_html/update.sh'])
|
|
|
|
|
print(request.form['payload'])
|
|
|
|
|
return 'Updated'
|
|
|
|
|
return 'GET method not supported'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# RUN
|
|
|
|
|
app.run(port="3132")
|
|
|
|
|