Skip to content

Commit

Permalink
Merge pull request #685 from doronz88/refactor/fix-fastapi-deprecatio…
Browse files Browse the repository at this point in the history
…n-warning

cdp_server: fix fastapi deprecation warning
  • Loading branch information
doronz88 authored Nov 21, 2023
2 parents 350b2a9 + cf9f0d4 commit 7503c8d
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions pymobiledevice3/services/web_protocol/cdp_server.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import asyncio
import uuid
from contextlib import asynccontextmanager

from fastapi import FastAPI, WebSocket
from fastapi.logger import logger
Expand All @@ -8,16 +9,18 @@
from pymobiledevice3.services.web_protocol.session_protocol import SessionProtocol
from pymobiledevice3.services.webinspector import WirTypes

app = FastAPI()


@app.on_event("startup")
async def startup_event():
@asynccontextmanager
async def lifespan(app: FastAPI):
app.state.inspector.connect()
yield


app = FastAPI(lifespan=lifespan)


@app.get('/json')
async def available_targets():
@app.get('/json{_:path}')
async def available_targets(_: str):
app.state.inspector.get_open_pages()
targets = []
for app_id in app.state.inspector.application_pages:
Expand Down

0 comments on commit 7503c8d

Please sign in to comment.