lolwtf this shit actually works
This commit is contained in:
commit
14dc277816
|
@ -0,0 +1,24 @@
|
|||
version: '3.8'
|
||||
|
||||
services:
|
||||
spaceapi:
|
||||
image: spaceapi
|
||||
build:
|
||||
context: src
|
||||
networks:
|
||||
- ingress
|
||||
- default
|
||||
deploy:
|
||||
labels:
|
||||
- "shepherd.auto-update=true"
|
||||
- "traefik.enable=true"
|
||||
- "traefik.http.services.spaceapi.loadbalancer.server.port=5000"
|
||||
- "traefik.http.routers.spaceapi.rule=Host(`api.montage2.de`)||Host(`api.chaoswest.tv`)"
|
||||
- "traefik.http.routers.spaceapi.tls=true"
|
||||
- "traefik.http.routers.spaceapi.tls.certresolver=default"
|
||||
|
||||
networks:
|
||||
ingress:
|
||||
external: true
|
||||
name: traefik
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
FROM python:alpine
|
||||
RUN mkdir /app
|
||||
WORKDIR /app
|
||||
COPY . /app
|
||||
RUN pip install -r requirements.txt
|
||||
ENTRYPOINT ["flask", "--app", "app", "run", "--host=0.0.0.0"]
|
|
@ -0,0 +1,43 @@
|
|||
import json
|
||||
import urllib.request
|
||||
|
||||
from flask import Flask, jsonify
|
||||
|
||||
app = Flask(__name__)
|
||||
|
||||
def get_jitsi_status():
|
||||
try:
|
||||
content = urllib.request.urlopen("https://talk.chaoswest.tv/room-census").read()
|
||||
census = json.loads(content)
|
||||
return any(room["room_name"] == "cws-lounge@muc.meet.jitsi" for room in census["room_census"])
|
||||
except Exception as e:
|
||||
print("shit got fucked up:")
|
||||
print(e)
|
||||
return None
|
||||
|
||||
@app.route("/spaceapi")
|
||||
def spaceapi():
|
||||
result = {
|
||||
'api': '0.13',
|
||||
'api_compatibility': ['14'],
|
||||
'space': 'chaoswest.tv',
|
||||
'logo': 'https://chaoswest.tv/logo.png',
|
||||
'url': 'https://chaoswest.tv',
|
||||
'location': {
|
||||
'lat': 50.47718,
|
||||
'lon': 12.33427,
|
||||
'address': 'FSN1-DC14',
|
||||
},
|
||||
'contact': {
|
||||
'mastodon': '@chaoswesttv@chaos.social',
|
||||
}
|
||||
}
|
||||
|
||||
status = get_jitsi_status()
|
||||
|
||||
if status:
|
||||
result["state"] = {
|
||||
'open': status
|
||||
}
|
||||
|
||||
return jsonify(result)
|
|
@ -0,0 +1 @@
|
|||
Flask>=3.0.1
|
Loading…
Reference in New Issue