|
|
|
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'))
|
|
|
|
|
|
|
|
|