Refactor code structure for improved readability and maintainability
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
# backend/main.py
|
||||
from fastapi import FastAPI
|
||||
from fastapi.middleware.cors import CORSMiddleware
|
||||
from livekit import api
|
||||
|
||||
app = FastAPI()
|
||||
|
||||
app.add_middleware(
|
||||
CORSMiddleware,
|
||||
allow_origins=["*"], # permite desde cualquier origen
|
||||
allow_methods=["*"],
|
||||
allow_headers=["*"],
|
||||
)
|
||||
|
||||
@app.get("/token")
|
||||
def get_token(room: str, user: str):
|
||||
access = api.AccessToken("devkey", "secret")
|
||||
grants = api.VideoGrants(
|
||||
room_join=True,
|
||||
room=room,
|
||||
can_publish=True,
|
||||
can_subscribe=True,
|
||||
)
|
||||
access.with_identity(user).with_grants(grants)
|
||||
token = access.to_jwt()
|
||||
return {"token": token}
|
||||
Reference in New Issue
Block a user