PUBLICERAD - Några fixar och nya texter

This commit is contained in:
2017-03-18 17:04:03 +01:00
parent ed7c8f1bda
commit c6a1a3d492
10 changed files with 15 additions and 7 deletions

View File

@@ -12,7 +12,7 @@ app = Flask(__name__)
Bootstrap(app)
Markdown(app)
pages = 'sidor/'
pages = os.path.dirname(os.path.realpath(__file__)) + '/sidor/'
categories = []
photos = []
@@ -24,6 +24,7 @@ for x in os.walk(pages):
num = len([x for x in x[2] if x.endswith(('.jpg','.JPG'))])
for i in range(num):
photos.append({'category': cat, 'num': i})
categories = sorted(categories)
@app.route('/randimg')
def randimg():
@@ -45,7 +46,7 @@ def thumbnails(category, num=0):
catdir = pages + '/' + category
thumbdir = catdir + '/thumbnails'
if not os.path.isfile('%s/%d.jpg' % (thumbdir, num)):
images = [x for x in next(os.walk(catdir))[2] if x.endswith('.jpg')]
images = sorted([x for x in next(os.walk(catdir))[2] if x.endswith('.jpg')])
if not os.path.exists(thumbdir):
os.makedirs(thumbdir)
imgin = '%s/%s' % (catdir, images[num])
@@ -58,7 +59,7 @@ def slides(category, num=0):
catdir = pages + '/' + category
thumbdir = catdir + '/slides'
if not os.path.isfile('%s/%d.jpg' % (thumbdir, num)):
images = [x for x in next(os.walk(catdir))[2] if x.endswith('.jpg')]
images = sorted([x for x in next(os.walk(catdir))[2] if x.endswith('.jpg')])
imgin = '%s/%s' % (catdir, images[num])
imgout = '%s/%d.jpg' % (thumbdir, num)
if not os.path.exists(thumbdir):
@@ -70,7 +71,7 @@ def slides(category, num=0):
@app.route('/<category>/<int:num>.jpg')
def cat_photo(category, num):
directory = pages + '/' + category
images = [x for x in next(os.walk(directory))[2] if x.endswith('.jpg')]
images = sorted([x for x in next(os.walk(directory))[2] if x.endswith('.jpg')])
try:
return send_from_directory(directory, images[num]);
except IndexError: