from .app import app from fastapi.requests import Request from fastapi.responses import PlainTextResponse @app.get('/status') @app.get('/status/') def status(request: Request): accepted_types = (s for s in request.headers.get('accept', '').split(',')) for accepted_type in accepted_types: if ';' in accepted_type: accepted_type, _ = accepted_type.split(';', 1) if accepted_type.strip() in ['*/*', 'text/plain']: break if accepted_type.strip() == 'application/json': return {'status': 'OK'} return PlainTextResponse('OK')