mirror of
https://github.com/simon987/od-database.git
synced 2025-04-19 10:26:44 +00:00
commit
38dfb657ed
2
.gitignore
vendored
2
.gitignore
vendored
@ -1 +1,3 @@
|
|||||||
.idea/
|
.idea/
|
||||||
|
/static/downloads/
|
||||||
|
!/static/downloads/README.md
|
29
app.py
29
app.py
@ -82,13 +82,30 @@ def from_timestamp(value):
|
|||||||
@app.route("/dl")
|
@app.route("/dl")
|
||||||
@cache.cached(120)
|
@cache.cached(120)
|
||||||
def downloads():
|
def downloads():
|
||||||
try:
|
# Get content of downloads directory
|
||||||
export_file_stats = os.stat("static/out.csv.lzm4")
|
dl_dir = "static/downloads/"
|
||||||
except FileNotFoundError:
|
dir_content = os.listdir(dl_dir)
|
||||||
logger.warning("No export file to display in /dl")
|
|
||||||
export_file_stats = None
|
|
||||||
|
|
||||||
return render_template("downloads.html", export_file_stats=export_file_stats)
|
# Make paths relative to working directory
|
||||||
|
# Only allow csv files
|
||||||
|
files = [
|
||||||
|
(name, os.path.join(dl_dir, name))
|
||||||
|
for name in dir_content
|
||||||
|
if name.find(".csv") != -1
|
||||||
|
]
|
||||||
|
|
||||||
|
# Stat files
|
||||||
|
# Remove any dirs placed accidentally
|
||||||
|
files = [
|
||||||
|
(f, full, os.stat(full))
|
||||||
|
for f, full in files
|
||||||
|
if os.path.isfile(full)
|
||||||
|
]
|
||||||
|
|
||||||
|
if len(files) == 0:
|
||||||
|
logger.warning("No export file to display in /dl")
|
||||||
|
|
||||||
|
return render_template("downloads.html", export_file_stats=files)
|
||||||
|
|
||||||
|
|
||||||
@app.route("/stats")
|
@app.route("/stats")
|
||||||
|
1
static/downloads/README.md
Normal file
1
static/downloads/README.md
Normal file
@ -0,0 +1 @@
|
|||||||
|
CSV exports of the database will be available here.
|
@ -11,6 +11,10 @@
|
|||||||
<p>Please let me know if you used the database in a project!</p>
|
<p>Please let me know if you used the database in a project!</p>
|
||||||
<p>The entire database is exported to CSV regularly</p>
|
<p>The entire database is exported to CSV regularly</p>
|
||||||
|
|
||||||
|
{% if not export_file_stats %}
|
||||||
|
<br/>
|
||||||
|
<p><em>No files available.</em></p>
|
||||||
|
{% else %}
|
||||||
<table class="table table-striped">
|
<table class="table table-striped">
|
||||||
|
|
||||||
<thead>
|
<thead>
|
||||||
@ -22,16 +26,17 @@
|
|||||||
</thead>
|
</thead>
|
||||||
|
|
||||||
<tbody>
|
<tbody>
|
||||||
{% if export_file_stats %}
|
{% for name, path, stat in export_file_stats %}
|
||||||
<tr>
|
<tr>
|
||||||
<td><a href="static/out.csv.xz">out.csv.xz</a></td>
|
<td><a href="{{ path }}">{{ name }}</a></td>
|
||||||
<td>{{ export_file_stats.st_size |filesizeformat }}</td>
|
<td>{{ stat.st_size |filesizeformat }}</td>
|
||||||
<td>{{ export_file_stats.st_mtime|datetime_format }} UTC</td>
|
<td>{{ stat.st_mtime|datetime_format }} UTC</td>
|
||||||
</tr>
|
</tr>
|
||||||
{% endif %}
|
{% endfor %}
|
||||||
</tbody>
|
</tbody>
|
||||||
|
|
||||||
</table>
|
</table>
|
||||||
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user