Spaces:
Runtime error
Runtime error
Commit
·
100e98e
1
Parent(s):
09a6e2b
fixing pydantic v1
Browse files- main/main.py +7 -15
main/main.py
CHANGED
@@ -7,7 +7,7 @@ import logging
|
|
7 |
from pathlib import Path
|
8 |
from fastapi.middleware.cors import CORSMiddleware
|
9 |
from .routes import router, init_router
|
10 |
-
from
|
11 |
|
12 |
def setup_logging():
|
13 |
"""Set up basic logging configuration"""
|
@@ -31,9 +31,9 @@ def create_app():
|
|
31 |
# Load configuration
|
32 |
config = load_config()
|
33 |
|
34 |
-
# Initialize
|
|
|
35 |
init_router(config)
|
36 |
-
api = InferenceApi(config)
|
37 |
|
38 |
# Create LitServer instance
|
39 |
server = ls.LitServer(
|
@@ -46,10 +46,10 @@ def create_app():
|
|
46 |
# Add CORS middleware
|
47 |
server.app.add_middleware(
|
48 |
CORSMiddleware,
|
49 |
-
allow_origins=["*"],
|
50 |
allow_credentials=True,
|
51 |
-
allow_methods=["*"],
|
52 |
-
allow_headers=["*"],
|
53 |
)
|
54 |
|
55 |
# Add our routes to the server's FastAPI app
|
@@ -62,12 +62,4 @@ def create_app():
|
|
62 |
raise
|
63 |
|
64 |
# Create the application instance
|
65 |
-
app = create_app()
|
66 |
-
|
67 |
-
if __name__ == "__main__":
|
68 |
-
# If we run this directly with python, we can still use the old method
|
69 |
-
config = load_config()
|
70 |
-
port = config.get("server", {}).get("port", 8001)
|
71 |
-
|
72 |
-
# Get the server instance from our app and run it
|
73 |
-
app.parent.run(port=port) # assuming the LitServer instance is stored as parent
|
|
|
7 |
from pathlib import Path
|
8 |
from fastapi.middleware.cors import CORSMiddleware
|
9 |
from .routes import router, init_router
|
10 |
+
from api import InferenceApi
|
11 |
|
12 |
def setup_logging():
|
13 |
"""Set up basic logging configuration"""
|
|
|
31 |
# Load configuration
|
32 |
config = load_config()
|
33 |
|
34 |
+
# Initialize API and router
|
35 |
+
api = InferenceApi()
|
36 |
init_router(config)
|
|
|
37 |
|
38 |
# Create LitServer instance
|
39 |
server = ls.LitServer(
|
|
|
46 |
# Add CORS middleware
|
47 |
server.app.add_middleware(
|
48 |
CORSMiddleware,
|
49 |
+
allow_origins=["*"],
|
50 |
allow_credentials=True,
|
51 |
+
allow_methods=["*"],
|
52 |
+
allow_headers=["*"],
|
53 |
)
|
54 |
|
55 |
# Add our routes to the server's FastAPI app
|
|
|
62 |
raise
|
63 |
|
64 |
# Create the application instance
|
65 |
+
app = create_app()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|