mirror of
https://github.com/FAUSheppy/python-flask-picture-factory
synced 2025-12-06 07:01:37 +01:00
feat: improve display of non-image entities
This commit is contained in:
@@ -140,7 +140,12 @@ def list():
|
||||
for f in files:
|
||||
retStringArr += [os.path.join(os.path.basename(root), f)]
|
||||
|
||||
return flask.render_template("index.html", paths=retStringArr)
|
||||
isPictureDict = dict()
|
||||
for p in retStringArr:
|
||||
isPicture = any([x in p for x in ["jpg", "png", "wep", "svg"]])
|
||||
isPictureDict.update({ p : isPicture })
|
||||
|
||||
return flask.render_template("index.html", paths=retStringArr, isPictureDict=isPictureDict)
|
||||
|
||||
@app.route("/upload", methods = ['GET', 'POST'])
|
||||
def upload():
|
||||
|
||||
@@ -20,16 +20,28 @@
|
||||
Public Images List:
|
||||
</p>
|
||||
<div class="overview">
|
||||
<p>
|
||||
{% for path in paths %}
|
||||
{% if not "cache" in path %}
|
||||
<a href="/m/{{ path }}">
|
||||
{% if isPictureDict[path] %}
|
||||
<a href="/m/{{ path }}" style="display: inline-block; float: left; margin: 5px;">
|
||||
<img alt="{{ path }}" src="/m/{{ path }}?encoding=webp&x=250"
|
||||
style="max-width: 250px; max-heigh: 250px; overflow: hidden; background: red;">
|
||||
</img>
|
||||
</a>
|
||||
{% else %}
|
||||
<a href="/m/{{ path }}" style="display: inline-block; float: left; magin: 5px;
|
||||
word-break: break-all;">
|
||||
<div style="height: 150px; width: 250px; background: aliceblue;">
|
||||
<p style="font-size: 40px; position: fixed; margin-left: 80px;
|
||||
margin-top: 20px;">❌</p>
|
||||
<br>
|
||||
<p style="margin-top: 80px; padding-left: 20px; padding-right: 20px">
|
||||
{{ path }}
|
||||
</p>
|
||||
</div>
|
||||
</a>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
</p>
|
||||
</div>
|
||||
</body>
|
||||
|
||||
Reference in New Issue
Block a user