This commit is contained in:
ville rantanen
2016-07-04 09:03:55 +03:00
parent 4ec90102de
commit 20d5e087cb
3 changed files with 8 additions and 3 deletions

View File

@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
# all the imports
import sqlite3, time, datetime, hashlib, os
import sqlite3, time, datetime, hashlib, os,re
from shutil import copyfile
from flask import Flask, request, session, g, redirect, url_for, \
abort, render_template, flash
@@ -13,6 +13,7 @@ DEBUG = False
SECRET_KEY = 'development key'
USERNAME = 'admin'
PASSWORD = 'default'
URLFINDER = re.compile("((news|telnet|nttp|file|http|ftp|https)://[^ ]+)")
# create our little application :)
app = Flask(__name__)
@@ -85,6 +86,9 @@ def scan_for_new_documents(id):
[shop, id])
g.db.commit()
def urlify(s):
return URLFINDER.sub(r'<a href="\1" target="_blank">\1</a>', s)
@app.before_request
def before_request():
g.db = connect_db()
@@ -126,6 +130,7 @@ def show_shop(shopid):
if "[ ]" in row or "[x]" in row:
icon=u"\u2714"
extra_class=""
row=urlify(row)
entries.append( dict(row=i, text=row, icon=icon, extra_class=extra_class) )
shared_to=[]
cur = g.db.execute('select * from shares')