Compare commits

..

3 commits

Author SHA1 Message Date
nsde 1c48174d47 Small improvements 2023-09-23 23:17:48 +02:00
nsde 25cbdb233e Added last update 2023-09-23 18:06:27 +02:00
nsde cb3175d149 Small fixes 2023-09-23 17:08:19 +02:00
6 changed files with 41 additions and 17 deletions

2
.gitignore vendored
View file

@ -1,5 +1,5 @@
!.gitkeep
imprint.html
data/
# Byte-compiled / optimized / DLL files

View file

@ -9,6 +9,8 @@ from dotenv import load_dotenv
load_dotenv()
# cache get_finances() for 5 minutes
def get_finances():
return requests.get(
url=f'{os.environ["CORE_API_URL"]}/finances',
@ -18,12 +20,16 @@ def get_finances():
timeout=5
).json()
def register(app):
@app.route('/finances')
def finances_view():
data = get_finances()
try:
data = get_finances()
except Exception:
return flask.Response('Error fetching finances from database. This might be cause the data is still being processed. Sorry.', status=500)
finances = {
'last_update': data['timestamp'],
'donations_total': round(sum([i['amount_usd'] for i in data['donations']])),
'donations_num': len(data['donations']),
'donations_avg': round(sum([i['amount_usd'] for i in data['donations']]) / len(data['donations']), 2),
@ -39,8 +45,13 @@ def register(app):
@app.route('/finances/json')
def finances_download():
try:
data = get_finances()
except Exception:
return flask.Response('Error fetching finances from database. This might be cause the data is still being processed. Sorry.', status=500)
virtual_file = io.StringIO()
json.dump(get_finances(), virtual_file, indent=4)
json.dump(data, virtual_file, indent=4)
name = f'finances-{time.strftime("%Y-%m-%d")}.json'
virtual_file.seek(0)

View file

@ -13,7 +13,8 @@
<b>API credits: </b> {{ user.credits or 0 }}<br>
<b>Secret API key (click to reveal): </b>
<br>
<span class="secret">{{ user.api_key or '-' }}</span>
<!-- <span class="secret">{{ user.api_key or '-' }}</span> -->
<span class="secret">{{ "API key not shown for security reasons" or '-' }}</span>
<br>(Click again to copy)
<br>
<script>

View file

@ -3,7 +3,14 @@
<main>
<h1>Our finances - transparency is key!</h1>
<p>
<b>Warning</b> - no guarantees can be made that this information is 100% accurate. Crypto currency prices are updated once every hour.
<b>Warning</b> - no guarantees can be made that this information is 100% accurate.
Crypto currency prices are being updated once every hour.
<br>
<b>As of: </b> <span id="lastUpdateDisplay">Loading...</span>
<script>
const unix_timestamp = {{ finances.last_update }};
lastUpdateDisplay.innerText = new Date(unix_timestamp * 1000).toLocaleString();
</script>
</p>
<a href="/finances/json" target="_blank">
@ -15,11 +22,17 @@
<h2>Donations</h2>
<div class="featured__facts box"><p>We have received <b>{{ finances.donations_num }} donations</b> so far.</p></div>
<div class="featured__facts box"><p>From donations, we received a total of <b>{{ finances.donations_total }} USD</b>.</p></div>
<div class="featured__facts box"><p>The average donation has an amount of <b>{{ finances.donations_avg }} USD</b>.
The largest donation is <b>{{ finances.donations_max }} USD</b>.</div>
<div class="featured__facts box"><p>Most people donated in <b>{{ finances.most_used_donation_currency }}</b>.</p></div>
<div class="featured__facts box"><p>
We have received <b>{{ finances.donations_num }} donations</b> so far,
totaling <b>{{ finances.donations_total }} USD</b>.
</p></div>
<div class="featured__facts box"><p>
The average donation has an amount of <b>{{ finances.donations_avg }} USD</b>.
Most people used <b>{{ finances.most_used_donation_currency }}</b> to donate.
</p></div>
<div class="featured__facts box"><p>
The largest donation is <b>{{ finances.donations_max }} USD</b>.
</p></div>
<!-- <img src="{{ finances.donations_chart_url }} alt="Donations chart"> -->

View file

@ -3,18 +3,18 @@
<header>
<h1>Free Generative AI for <span class="special-gradient">Everyone</span></h1>
<h3>Open source ・ no CC required</h3>
<h3>Open source</h3>
<a href="https://discord.nova-oss.com" target="_blank">
<button class="special">
<i class="bi bi-discord"></i>
Join 3,400+ members
Join 3,800+ members
</button>
</a>
<a href="/login">
<!-- <a href="/login">
<button class="secondary">
Log in <mark>beta</mark>
</button>
</a>
</a> -->
<br>
</header>
<main>

View file

@ -1 +0,0 @@
<meta http-equiv="REFRESH" content="0; url=https://youtu.be/dQw4w9WgXcQ">