Add qrcode generator endpoint
This commit is contained in:
parent
bc9bf71824
commit
3b927522e3
3 changed files with 53 additions and 1 deletions
|
@ -8,6 +8,7 @@ from .connect import get_connection
|
|||
from .room import Room
|
||||
from .song import Song, init_db, get_song_by_title_artist, add_song_in_db
|
||||
from .song_fetch import lastfm_query_search, download_song_mp3
|
||||
from .qrcode_gen import generate_qr
|
||||
|
||||
from typing import Any
|
||||
|
||||
|
@ -174,5 +175,22 @@ def add_song():
|
|||
return {"artist": info.artist, "title": info.title, "tags": info.tags, "image_id": info.img_id}
|
||||
|
||||
|
||||
@app.get("/api/room/qrcode")
|
||||
def room_qrcode():
|
||||
if (room_id := request.args.get("room")) is None:
|
||||
return error("Missing room id")
|
||||
|
||||
if (pin := request.args.get("pin")) is not None:
|
||||
pin = int(pin)
|
||||
|
||||
stream = generate_qr(
|
||||
base_uri="https://chillbox.leoinvents.com",
|
||||
room_id=int(room_id),
|
||||
pin=pin,
|
||||
)
|
||||
|
||||
return Response(stream, content_type="image/jpeg")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
socketio.run(app, debug=True)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue