parent
29a38cfbe2
commit
bb4fc9e488
5 changed files with 47 additions and 4 deletions
|
@ -1,11 +1,12 @@
|
|||
import os
|
||||
import random
|
||||
|
||||
from flask import Blueprint, render_template
|
||||
from flask import Blueprint, render_template, jsonify
|
||||
from .auth import oidc
|
||||
from .port_utils import get_user_ports
|
||||
from dotenv import load_dotenv
|
||||
|
||||
main = Blueprint('main', __name__)
|
||||
main = Blueprint('main', __name__, static_folder='static')
|
||||
|
||||
load_dotenv()
|
||||
|
||||
|
@ -33,7 +34,19 @@ def dashboard():
|
|||
has_server = os.path.exists(server_path)
|
||||
ip = os.getenv("SERVER_IP")
|
||||
ports = get_user_ports(username)
|
||||
if (has_server):
|
||||
|
||||
if has_server:
|
||||
return render_template('dashboard.html', username=username, ip=ip, ports=ports)
|
||||
else:
|
||||
return render_template('setup.html', username=username, ip=ip, ports=ports)
|
||||
|
||||
|
||||
@main.route("/ads/list")
|
||||
def list_ads():
|
||||
ads_dir = os.path.join(main.static_folder, "ads")
|
||||
files = [
|
||||
f"/static/ads/{f}"
|
||||
for f in os.listdir(ads_dir)
|
||||
if f.lower().endswith(".png")
|
||||
]
|
||||
return jsonify(files)
|
||||
|
|
BIN
app/static/ads/giantKitten.png
Normal file
BIN
app/static/ads/giantKitten.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 4.1 MiB |
BIN
app/static/ads/iPhoneAd.png
Normal file
BIN
app/static/ads/iPhoneAd.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 211 KiB |
|
@ -86,6 +86,20 @@ h2 {
|
|||
transition: all 0.3s ease;
|
||||
}
|
||||
|
||||
/* Ads */
|
||||
.ad-banner {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
margin: 20px 0;
|
||||
}
|
||||
|
||||
.ad-banner img {
|
||||
width: 200px;
|
||||
height: auto;
|
||||
border-radius: 12px;
|
||||
box-shadow: 0 0 12px rgba(0, 0, 0, 0.3);
|
||||
}
|
||||
|
||||
/* Tabs */
|
||||
.tabs {
|
||||
display: grid;
|
||||
|
|
|
@ -30,7 +30,8 @@
|
|||
<div class="dashboard-card">
|
||||
{% block content %}{% endblock %}
|
||||
</div>
|
||||
<p>Wersja: v0.1</p>
|
||||
<div id="ad-banner" class="ad-banner"></div>
|
||||
<p>Wersja: v0.2</p>
|
||||
<script>
|
||||
window.addEventListener('dragover', e => e.preventDefault());
|
||||
window.addEventListener('drop', e => e.preventDefault());
|
||||
|
@ -108,6 +109,21 @@
|
|||
}
|
||||
setInterval(createParticle, 100);
|
||||
|
||||
fetch("/ads/list")
|
||||
.then(response => response.json())
|
||||
.then(images => {
|
||||
if (images.length === 0) return;
|
||||
const randomImage = images[Math.floor(Math.random() * images.length)];
|
||||
const img = document.createElement("img");
|
||||
img.src = randomImage;
|
||||
img.alt = "Ad Banner";
|
||||
img.style.maxWidth = "100%";
|
||||
img.style.height = "auto";
|
||||
img.style.borderRadius = "8px";
|
||||
img.style.boxShadow = "0 0 12px rgba(0,0,0,0.3)";
|
||||
document.getElementById("ad-banner").appendChild(img);
|
||||
});
|
||||
|
||||
animate();
|
||||
</script>
|
||||
</body>
|
||||
|
|
Loading…
Add table
Reference in a new issue