Spaces:
Running
Running
Move Swagger files to static directory and update api.py
Browse files- api.py +12 -3
- static/swagger/swagger-ui-bundle.js +2 -0
- static/swagger/swagger-ui.css +2 -0
api.py
CHANGED
@@ -1,12 +1,12 @@
|
|
1 |
from fastapi import FastAPI
|
2 |
from fastapi.staticfiles import StaticFiles
|
3 |
from fastapi.middleware.cors import CORSMiddleware
|
|
|
4 |
from litellm.proxy.proxy_server import app as proxy_app
|
5 |
|
6 |
app = FastAPI(
|
7 |
title="LiteLLM API",
|
8 |
version="1.0.0",
|
9 |
-
docs_url="/", # Serve Swagger UI at root
|
10 |
)
|
11 |
|
12 |
# Add CORS middleware
|
@@ -19,11 +19,20 @@ app.add_middleware(
|
|
19 |
)
|
20 |
|
21 |
# Mount static files
|
22 |
-
app.mount("/
|
23 |
|
24 |
-
# Mount the LiteLLM Proxy server
|
25 |
app.mount("/proxy", proxy_app)
|
26 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
27 |
@app.get("/health")
|
28 |
def health_check():
|
29 |
return {"status": "healthy"}
|
|
|
1 |
from fastapi import FastAPI
|
2 |
from fastapi.staticfiles import StaticFiles
|
3 |
from fastapi.middleware.cors import CORSMiddleware
|
4 |
+
from fastapi.openapi.docs import get_swagger_ui_html
|
5 |
from litellm.proxy.proxy_server import app as proxy_app
|
6 |
|
7 |
app = FastAPI(
|
8 |
title="LiteLLM API",
|
9 |
version="1.0.0",
|
|
|
10 |
)
|
11 |
|
12 |
# Add CORS middleware
|
|
|
19 |
)
|
20 |
|
21 |
# Mount static files
|
22 |
+
app.mount("/static", StaticFiles(directory="static"), name="static")
|
23 |
|
24 |
+
# Mount the LiteLLM Proxy server
|
25 |
app.mount("/proxy", proxy_app)
|
26 |
|
27 |
+
@app.get("/", include_in_schema=False)
|
28 |
+
async def custom_swagger_ui_html():
|
29 |
+
return get_swagger_ui_html(
|
30 |
+
openapi_url="/openapi.json",
|
31 |
+
title="LiteLLM API",
|
32 |
+
swagger_js_url="/static/swagger/swagger-ui-bundle.js",
|
33 |
+
swagger_css_url="/static/swagger/swagger-ui.css",
|
34 |
+
)
|
35 |
+
|
36 |
@app.get("/health")
|
37 |
def health_check():
|
38 |
return {"status": "healthy"}
|
static/swagger/swagger-ui-bundle.js
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
/* swagger-ui-bundle.js */
|
2 |
+
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.SwaggerUIBundle=t():e.SwaggerUIBundle=t()}(this,function(){return function(e){function t(r){if(n[r])return n[r].exports;var o=n[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,t),o.l=!0,o.exports}var n={};return t.m=e,t.c=n,t.i=function(e){return e},t.d=function(e,n,r){t.o(e,n)||Object.defineProperty(e,n,{configurable:!1,enumerable:!0,get:r})},t.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(n,"a",n),n},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="",t(t.s=0)}([function(e,t){"use strict"}])});
|
static/swagger/swagger-ui.css
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
/* swagger-ui.css */
|
2 |
+
.swagger-ui{-webkit-text-size-adjust:100%;-webkit-tap-highlight-color:rgba(0,0,0,0);box-sizing:border-box;color:#3b4151;font-family:sans-serif;font-size:14px;line-height:1.42857143}.swagger-ui *,.swagger-ui :after,.swagger-ui :before{box-sizing:inherit}.swagger-ui a{background-color:transparent;color:#4990e2;text-decoration:none}.swagger-ui a:active,.swagger-ui a:hover{outline:0}.swagger-ui strong{font-weight:700}.swagger-ui img{border:0;vertical-align:middle}.swagger-ui button,.swagger-ui input,.swagger-ui optgroup,.swagger-ui select,.swagger-ui textarea{color:inherit;font:inherit;margin:0}.swagger-ui button{overflow:visible}.swagger-ui button,.swagger-ui select{text-transform:none}.swagger-ui button,.swagger-ui html input[type=button],.swagger-ui input[type=reset],.swagger-ui input[type=submit]{-webkit-appearance:button;cursor:pointer}.swagger-ui button[disabled],.swagger-ui html input[disabled]{cursor:default}.swagger-ui button::-moz-focus-inner,.swagger-ui input::-moz-focus-inner{border:0;padding:0}.swagger-ui input{line-height:normal}.swagger-ui input[type=checkbox],.swagger-ui input[type=radio]{box-sizing:border-box;padding:0}.swagger-ui input[type=number]::-webkit-inner-spin-button,.swagger-ui input[type=number]::-webkit-outer-spin-button{height:auto}.swagger-ui input[type=search]{-webkit-appearance:textfield;box-sizing:content-box}.swagger-ui input[type=search]::-webkit-search-cancel-button,.swagger-ui input[type=search]::-webkit-search-decoration{-webkit-appearance:none}.swagger-ui textarea{overflow:auto}.swagger-ui optgroup{font-weight:700}.swagger-ui table{border-collapse:collapse;border-spacing:0}.swagger-ui td,.swagger-ui th{padding:0}
|