Spaces:
Running on Zero
Running on Zero
temporary forwarding check
Browse files
app.py
CHANGED
|
@@ -142,6 +142,13 @@ def home():
|
|
| 142 |
return PlainTextResponse(f'm.ai API is running. The website is {SITE}\n', headers=NO_STORE)
|
| 143 |
|
| 144 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 145 |
@server.api_route('/api/{path:path}', methods=['GET', 'HEAD', 'POST'], include_in_schema=False)
|
| 146 |
async def api(path: str, request: Request):
|
| 147 |
if int(request.headers.get('content-length') or 0) > BODY_LIMIT:
|
|
|
|
| 142 |
return PlainTextResponse(f'm.ai API is running. The website is {SITE}\n', headers=NO_STORE)
|
| 143 |
|
| 144 |
|
| 145 |
+
if os.environ.get('SHOW_FORWARDING') == 'yes': # temporary: shows a caller its own forwarding headers
|
| 146 |
+
@server.get('/forwarding', include_in_schema=False)
|
| 147 |
+
def forwarding(request: Request):
|
| 148 |
+
return JSONResponse({k: v for k, v in request.headers.items() if k.startswith('x-') or k in ('forwarded', 'via')}
|
| 149 |
+
| {'client': request.client and request.client.host}, headers=NO_STORE)
|
| 150 |
+
|
| 151 |
+
|
| 152 |
@server.api_route('/api/{path:path}', methods=['GET', 'HEAD', 'POST'], include_in_schema=False)
|
| 153 |
async def api(path: str, request: Request):
|
| 154 |
if int(request.headers.get('content-length') or 0) > BODY_LIMIT:
|