Ein kleines Projekt um Markdown Dokumente zu Presenten.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

51 lines
1.2 KiB

import os, uuid
from flask import (
Blueprint, flash, g, redirect, render_template, request, url_for, session
)
from app.auth import login_required
from app.db import get_db
bp = Blueprint('index', __name__)
@bp.route('/')
@login_required
def index():
db = get_db()
mdFiles = db.execute(
'SELECT * FROM markdownFile WHERE creator = ?', (session['user_id'],)
).fetchall()
return render_template('index.html', mdFiles=mdFiles)
@bp.route('/qr/<uuid>')
@login_required
def qrView(uuid):
qrCode = '/static/uploads/' + str(uuid) + '.png'
return render_template('qrView.html', qr = qrCode)
@bp.route('/viewfile/<uuid>', methods=('GET', 'POST'))
@login_required
def viewfile(uuid):
db = get_db()
mdFile = db.execute(
'SELECT * FROM markdownFile WHERE uuid = ?', (uuid,)
).fetchone()
return render_template('mdView.html', mdFile=mdFile['body'])
@bp.route('/delete/<uuid>', methods=('GET', 'POST'))
@login_required
def deletefile(uuid):
db = get_db()
db.execute(
'DELETE FROM markdownFile WHERE uuid = ?', (uuid,)
)
db.commit()
os.remove(os.getcwd() + '/app/static/uploads/' + uuid + '.png')
return redirect(url_for('index'))