PUBLICERAD - Några fixar och nya texter
This commit is contained in:
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user