fix static images paths

This commit is contained in:
deflax 2024-09-07 18:29:41 +00:00
parent 84516d3aeb
commit 3fbb7580c7
2 changed files with 20 additions and 22 deletions

View file

@ -6,7 +6,7 @@ import json
import requests import requests
from datetime import datetime from datetime import datetime
from flask import Flask, render_template, jsonify, request, abort from flask import Flask, render_template, jsonify, request, abort
from flask.helpers import send_file from flask.helpers import send_file, send_from_directory
from apscheduler.schedulers.background import BackgroundScheduler from apscheduler.schedulers.background import BackgroundScheduler
from core_client import Client from core_client import Client
from ffmpeg import FFmpeg, Progress from ffmpeg import FFmpeg, Progress
@ -312,9 +312,15 @@ scheduler.get_job('core_api_sync').modify(next_run_time=datetime.now())
# Start the scheduler # Start the scheduler
scheduler.start() scheduler.start()
# Flask API ## Flask
# Frontend
@app.route('/', methods=['GET']) @app.route('/', methods=['GET'])
def root_route(): def root_route():
return render_template('index.html')
# API
@app.route('/about', methods=['GET'])
def about_route():
about_json = { 'about': 'DeflaxTV API' } about_json = { 'about': 'DeflaxTV API' }
return jsonify(about_json) return jsonify(about_json)
@ -335,13 +341,6 @@ def database_route():
return jsonify(database) return jsonify(database)
# Images # Images
@app.route("/img/<file_name>", methods=['GET'])
def img_route(file_name):
reqfile = f'./img/{file_name}'
if not os.path.exists(reqfile):
abort(404)
return send_file(reqfile, mimetype='image/png')
@app.route("/thumb/<file_name>", methods=['GET']) @app.route("/thumb/<file_name>", methods=['GET'])
def thumb_route(file_name): def thumb_route(file_name):
reqfile = f'{rec_path}/thumb/{file_name}' reqfile = f'{rec_path}/thumb/{file_name}'
@ -366,7 +365,7 @@ def video_download_route(file_name):
logger_content.warning(str(reqfile) + ' download') logger_content.warning(str(reqfile) + ' download')
return send_file(reqfile, as_attachment=True, download_name=file_name) return send_file(reqfile, as_attachment=True, download_name=file_name)
@app.route('/video/watch/<file_name_no_extension>', methods=['GET']) @app.route("/video/watch/<file_name_no_extension>", methods=['GET'])
def video_watch_route(file_name_no_extension): def video_watch_route(file_name_no_extension):
video_file = f'{file_name_no_extension}.mp4' video_file = f'{file_name_no_extension}.mp4'
thumb_file = f'{file_name_no_extension}.png' thumb_file = f'{file_name_no_extension}.png'

View file

@ -10,7 +10,7 @@
<meta property="og:url" content=https://deflax.net> <meta property="og:url" content=https://deflax.net>
<meta property="og:description" content="The landing page of the flaxnet"> <meta property="og:description" content="The landing page of the flaxnet">
<meta property="og:type" content=product> <meta property="og:type" content=product>
<meta property="og:image" content=https://deflax.net/img/logo.png> <meta property="og:image" content=https://deflax.net/static/images/logo.png>
<meta name="viewport" content="width=device-width, initial-scale=1"> <meta name="viewport" content="width=device-width, initial-scale=1">
<title>▷ deflax.net</title> <title>▷ deflax.net</title>
@ -29,7 +29,7 @@
<nav class="navbar navbar-expand-sm fixed-top navbar-dark bg-dark"> <nav class="navbar navbar-expand-sm fixed-top navbar-dark bg-dark">
<div class="container-fluid"> <div class="container-fluid">
<a class="navbar-brand" href="#" style="padding-left: 8.5%;"> <a class="navbar-brand" href="#" style="padding-left: 8.5%;">
<img src="img/logo.png" alt="" width="40" height="40" class="d-inline-block align-text-center"> <img src="static/images/logo.png" alt="" width="40" height="40" class="d-inline-block align-text-center">
deflax.net deflax.net
</a> </a>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation"> <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
@ -58,7 +58,7 @@
</div> </div>
<div class="col-xs-12 col-md-10"> <div class="col-xs-12 col-md-10">
<div class="content"> <div class="content">
<video controls crossorigin playsinline poster="img/poster.png"> <video controls crossorigin playsinline poster="static/images/poster.png">
</video> </video>
<script> <script>
document.addEventListener('DOMContentLoaded', () => { document.addEventListener('DOMContentLoaded', () => {
@ -281,25 +281,24 @@ document.addEventListener('DOMContentLoaded', () => {
<div class="col-xs-12 col-md-2"> <div class="col-xs-12 col-md-2">
<div class="content"> <div class="content">
<h2>Upstreams</h2> <h2>Upstreams</h2>
<p><a href='https://youtube.com/@daniel.deflax' target=_blank><img src="img/icons8-youtube-96.png"></a></p> <p><a href='https://youtube.com/@daniel.deflax' target=_blank><img src="static/images/icons8-youtube-96.png"></a></p>
<p><a href='https://www.twitch.tv/deflaxtv' target_blank><img src="img/icons8-twitch-96.png"></a></p> <p><a href='https://www.twitch.tv/deflaxtv' target_blank><img src="static/images/icons8-twitch-96.png"></a></p>
<p><a href='https://soundcloud.com/deflax' target=_blank><img src="img/icons8-soundcloud-96.png"></a></p> <p><a href='https://soundcloud.com/deflax' target=_blank><img src="static/images/icons8-soundcloud-96.png"></a></p>
<p><a href='https://facebook.com/daniel.default' target=_blank><img src="img/icons8-facebook-96.png"></a></p> <p><a href='https://facebook.com/daniel.default' target=_blank><img src="static/images/icons8-facebook-96.png"></a></p>
<p><a href='https://instagram.com/daniel.deflax' target=_blank><img src="img/icons8-instagram-96.png"></a></p> <p><a href='https://instagram.com/daniel.deflax' target=_blank><img src="static/images/icons8-instagram-96.png"></a></p>
</div> </div>
</div> </div>
<div class="col-xs-12 col-md-2"> <div class="col-xs-12 col-md-2">
<div class="content"> <div class="content">
<h2>Backroom</h2> <h2>Backroom</h2>
<p><a href='https://discord.com/invite/KKGtn6GCE3' target=_blank><img src="img/icons8-discord-96.png"></a></p> <p><a href='https://discord.com/invite/KKGtn6GCE3' target=_blank><img src="static/images/icons8-discord-96.png"></a></p>
<p><a href='https://git.deflax.net/deflax' target=_blank rel="me"><img src="img/forgejo-96.png"></a></p>
</div> </div>
</div> </div>
<div class="col-xs-12 col-md-4"> <div class="col-xs-12 col-md-4">
<div class="content"> <div class="content">
<h2>Friends</h2> <h2>Friends</h2>
<p><a href='https://jungletrain.net/' target=_blank><img src="img/jtlogo.png" height="64"></a></p> <p><a href='https://jungletrain.net/' target=_blank><img src="static/images/jtlogo.png" height="64"></a></p>
<p><a href='http://freerave.cz/' target=_blank><img src="img/freeravemini.png" height="64"></a></p> <p><a href='http://freerave.cz/' target=_blank><img src="static/images/freeravemini.png" height="64"></a></p>
<p><a href='http://iwayhigh.net/' target=_blank>|iway|High</a></p> <p><a href='http://iwayhigh.net/' target=_blank>|iway|High</a></p>
<p><a href='https://anima.sknt.ru/' target=_blank>Anima Amoris</a></p> <p><a href='https://anima.sknt.ru/' target=_blank>Anima Amoris</a></p>
<p>You! 🙃</p> <p>You! 🙃</p>