Compare commits
4 commits
f97e52fb29
...
ed3da87da5
Author | SHA256 | Date | |
---|---|---|---|
ed3da87da5 | |||
44af0418bf | |||
0e04fcc882 | |||
1196e25a53 |
43
site/app.py
|
@ -1,6 +1,26 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
from flask import Flask, render_template, make_response
|
||||
from flask import Flask, render_template, make_response, send_from_directory
|
||||
import requests
|
||||
import os
|
||||
|
||||
apiRoot = "https://api.listenbrainz.org"
|
||||
user = "everypizza"
|
||||
|
||||
buttons = [
|
||||
("assets/88x31s/benjae.nekoweb.org.gif", "https://benjae.nekoweb.org"),
|
||||
("assets/88x31s/freetards.xyz.gif", "https://freetards.xyz"),
|
||||
("assets/88x31s/fsky.io.webp", "https://fsky.io"),
|
||||
("assets/88x31s/purplebored.pl.gif", "https://purplebored.pl"),
|
||||
("assets/88x31s/squarebowl.club.gif", "https://squarebowl.club"),
|
||||
("assets/88x31s/synth.download.svg", "https://synth.download"),
|
||||
("assets/88x31s/telepath.im.png", "https://telepath.im"),
|
||||
("assets/88x31s/voxel.fsky.io.webp", "https://voxel.fsky.io"),
|
||||
]
|
||||
|
||||
nyxbuttons = [
|
||||
("assets/88x31s/nyx.everypizza.im.webp", "https://nyx.everypizza.im"),
|
||||
]
|
||||
|
||||
app = Flask(__name__)
|
||||
|
||||
|
@ -23,7 +43,17 @@ def increment_visitor_count():
|
|||
@app.route('/')
|
||||
def index():
|
||||
increment_visitor_count()
|
||||
return render_template('index.j2', visitor=get_visitor_count())
|
||||
data = requests.get(apiRoot + "/1/user/" + user + "/playing-now")
|
||||
if not data.json()['payload']['listens']:
|
||||
nowPlaying = False
|
||||
nowPlayingString = "nothing is playing right now."
|
||||
else:
|
||||
track = data.json()['payload']['listens'][0]['track_metadata']['track_name']
|
||||
artist = data.json()['payload']['listens'][0]['track_metadata']['artist_name']
|
||||
album = data.json()['payload']['listens'][0]['track_metadata']['release_name']
|
||||
nowPlayingString = f"now playing for <b>{user}</b>: <b>{track}</b> by <b>{artist}</b> from <b>{album}</b>"
|
||||
|
||||
return render_template('index.j2', np=nowPlayingString, visitor=get_visitor_count(), buttons=buttons, nyxbuttons=nyxbuttons)
|
||||
|
||||
@app.route('/assets/index.css')
|
||||
def indexStyle():
|
||||
|
@ -32,5 +62,14 @@ def indexStyle():
|
|||
response.mimetype = "text/css"
|
||||
return response
|
||||
|
||||
@app.route('/static/assets/88x31s/<path:filename>')
|
||||
def serve_dir(filename):
|
||||
directory = 'templates/assets/88x31s'
|
||||
return send_from_directory(directory, filename)
|
||||
|
||||
@app.route('/todo')
|
||||
def todo():
|
||||
return render_template('todo.html')
|
||||
|
||||
if __name__ == '__main__':
|
||||
app.run(host="0.0.0.0", port=8080)
|
||||
|
|
BIN
site/templates/assets/88x31s/benjae.nekoweb.org.gif
Normal file
After Width: | Height: | Size: 466 B |
BIN
site/templates/assets/88x31s/freetards.xyz.gif
Normal file
After Width: | Height: | Size: 680 B |
BIN
site/templates/assets/88x31s/fsky.io.webp
Normal file
After Width: | Height: | Size: 486 B |
BIN
site/templates/assets/88x31s/nyx.everypizza.im.webp
Normal file
After Width: | Height: | Size: 198 B |
BIN
site/templates/assets/88x31s/purplebored.pl.gif
Normal file
After Width: | Height: | Size: 1.7 KiB |
BIN
site/templates/assets/88x31s/squarebowl.club.gif
Normal file
After Width: | Height: | Size: 5.6 KiB |
1
site/templates/assets/88x31s/synth.download.svg
Normal file
After Width: | Height: | Size: 5.2 KiB |
BIN
site/templates/assets/88x31s/telepath.im.png
Normal file
After Width: | Height: | Size: 1 KiB |
BIN
site/templates/assets/88x31s/voxel.fsky.io.webp
Normal file
After Width: | Height: | Size: 528 B |
1
site/templates/assets/broken/isekai.rocks.svg
Normal file
|
@ -0,0 +1 @@
|
|||
<svg viewBox="0 0 88 31" xmlns="http://www.w3.org/2000/svg"><foreignObject x="0" y="0" width="88" height="31"><pre xmlns="http://www.w3.org/1999/xhtml" style="color-scheme:light dark;display: block;width:88px;height:31px;font-size:8px;box-shadow:1px 1px 0 0 inset,graytext -1px -1px 0 0 inset;padding:5px;box-sizing:border-box;color:blue;background:red;margin:0">>Snit was here</pre></foreignObject></svg>
|
After Width: | Height: | Size: 409 B |
|
@ -70,8 +70,37 @@
|
|||
<p>
|
||||
<ul>
|
||||
<li>
|
||||
<a href="todo.html">to-do list</a>
|
||||
<a href="todo">to-do list</a>
|
||||
</li>
|
||||
</ul>
|
||||
</p>
|
||||
<h2>
|
||||
now playing
|
||||
</h2>
|
||||
<p>
|
||||
{{ np }}
|
||||
<br>
|
||||
<small>
|
||||
data is from listenbrainz.
|
||||
</small>
|
||||
</p>
|
||||
<h2>
|
||||
88x31s
|
||||
</h2>
|
||||
<p>
|
||||
{% for image, link in buttons %}
|
||||
<a href="{{ link }}">
|
||||
<img src="/static/{{ image }}" alt="{{ image }}" width="88" height="31">
|
||||
</a>
|
||||
{% endfor %}
|
||||
</p>
|
||||
<h3>
|
||||
this one's 88x31
|
||||
</h3>
|
||||
<p>
|
||||
{% for image, link in nyxbuttons %}
|
||||
<a href="{{ link }}">
|
||||
<img src="/static/{{ image }}" alt="{{ image }}" width="88" height="31">
|
||||
</a>
|
||||
{% endfor %}
|
||||
</body>
|
||||
|
|
|
@ -21,9 +21,6 @@
|
|||
<li>
|
||||
look into more optimizations
|
||||
</li>
|
||||
<li>
|
||||
switch this site to a flask app
|
||||
</li>
|
||||
</ul>
|
||||
</p>
|
||||
</body>
|
||||
|
|