wip: backend
This commit is contained in:
parent
8a9df4871f
commit
a93e39d984
@ -24,7 +24,8 @@ app:
|
|||||||
real_url: https://www.thsf.net
|
real_url: https://www.thsf.net
|
||||||
pretalx:
|
pretalx:
|
||||||
url: https://23.thsf.net
|
url: https://23.thsf.net
|
||||||
apikey: sdfsdfsdf
|
apiprefix: api
|
||||||
|
apikey: bb770a53b15467dfb67c03d178004aca9e4819d6
|
||||||
event: thsf-2023
|
event: thsf-2023
|
||||||
schedule: wip
|
schedule: wip
|
||||||
|
|
||||||
|
@ -3,3 +3,4 @@ wheel
|
|||||||
flask
|
flask
|
||||||
gunicorn
|
gunicorn
|
||||||
pyYAML
|
pyYAML
|
||||||
|
requests
|
||||||
|
@ -22,6 +22,7 @@ install_requires =
|
|||||||
flask
|
flask
|
||||||
gunicorn
|
gunicorn
|
||||||
pyYAML
|
pyYAML
|
||||||
|
request
|
||||||
|
|
||||||
[options.packages.find]
|
[options.packages.find]
|
||||||
where = src
|
where = src
|
||||||
|
@ -3,6 +3,7 @@ import logging
|
|||||||
from logging import config
|
from logging import config
|
||||||
import yaml
|
import yaml
|
||||||
from flask import Flask, render_template, redirect, request, url_for
|
from flask import Flask, render_template, redirect, request, url_for
|
||||||
|
from thsf.backend import Backend
|
||||||
|
|
||||||
|
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
@ -30,6 +31,9 @@ try:
|
|||||||
app.config["SECRET_KEY"] = app.local_config["app"]["secret_key"]
|
app.config["SECRET_KEY"] = app.local_config["app"]["secret_key"]
|
||||||
app.config["LANGUAGES"] = app.local_config["app"]["languages"]
|
app.config["LANGUAGES"] = app.local_config["app"]["languages"]
|
||||||
config.dictConfig(app.local_config["log"])
|
config.dictConfig(app.local_config["log"])
|
||||||
|
backend = Backend(url=app.local_config["pretalx"]["url"],
|
||||||
|
apiprefix=app.local_config["pretalx"]["apiprefix"],
|
||||||
|
apikey=app.local_config["pretalx"]["apikey"])
|
||||||
except Exception as err:
|
except Exception as err:
|
||||||
logger.critical("[{}] {}".format(err.__class__, str(err)))
|
logger.critical("[{}] {}".format(err.__class__, str(err)))
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
@ -56,6 +60,7 @@ def index():
|
|||||||
|
|
||||||
@app.route('/planning', methods=['GET'])
|
@app.route('/planning', methods=['GET'])
|
||||||
def planning():
|
def planning():
|
||||||
|
backend.get(endpoint=f"events/{app.local_config['pretalx']['event']}/schedules/{app.local_config['pretalx']['schedule']}")
|
||||||
return "planning"
|
return "planning"
|
||||||
|
|
||||||
@app.route('/concerts', methods=['GET'])
|
@app.route('/concerts', methods=['GET'])
|
||||||
|
15
src/thsf/backend/__init__.py
Normal file
15
src/thsf/backend/__init__.py
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
import requests
|
||||||
|
|
||||||
|
|
||||||
|
class Backend(url, apiprefix, apikey):
|
||||||
|
def __init__(self, url, apiprefix, apikey):
|
||||||
|
self.url = url
|
||||||
|
self.apiprefix = apiprefix
|
||||||
|
self.apikey = apikey
|
||||||
|
self.session = requests.Session()
|
||||||
|
|
||||||
|
def get(self, endpoint, params=None):
|
||||||
|
url = f"{self.url}/{self.apiprefix}/{endpoint}"
|
||||||
|
headers = {f"Authorization: Token {self.apikey}"}
|
||||||
|
return self.session.get(url, **{"params": params, "headers": headers})
|
||||||
|
|
@ -23,7 +23,8 @@
|
|||||||
<div id="navbar_wrapper">
|
<div id="navbar_wrapper">
|
||||||
<i class="button tooltip black fa-regular fa-calendar"
|
<i class="button tooltip black fa-regular fa-calendar"
|
||||||
title="Programme"
|
title="Programme"
|
||||||
alt="Programme">
|
alt="Programme"
|
||||||
|
onclick="document.location='/planning'">
|
||||||
<span class="tooltiptext thin">Programme</span>
|
<span class="tooltiptext thin">Programme</span>
|
||||||
</i>
|
</i>
|
||||||
<i class="button tooltip black fa-solid fa-map-location-dot"
|
<i class="button tooltip black fa-solid fa-map-location-dot"
|
||||||
|
Loading…
Reference in New Issue
Block a user