Merge branch 'db' of https://github.com/logspace-ai/langflow into db
This commit is contained in:
commit
7a6472f103
3 changed files with 27 additions and 14 deletions
|
|
@ -1,5 +1,6 @@
|
||||||
import sys
|
import sys
|
||||||
import time
|
import time
|
||||||
|
from fastapi import FastAPI
|
||||||
import httpx
|
import httpx
|
||||||
from multiprocess import Process, cpu_count # type: ignore
|
from multiprocess import Process, cpu_count # type: ignore
|
||||||
import platform
|
import platform
|
||||||
|
|
@ -145,18 +146,16 @@ def serve(
|
||||||
update_settings(
|
update_settings(
|
||||||
config, dev=dev, database_url=database_url, remove_api_keys=remove_api_keys
|
config, dev=dev, database_url=database_url, remove_api_keys=remove_api_keys
|
||||||
)
|
)
|
||||||
app = create_app()
|
|
||||||
# get the directory of the current file
|
# get the directory of the current file
|
||||||
if not path:
|
if not path:
|
||||||
frontend_path = Path(__file__).parent
|
frontend_path = Path(__file__).parent
|
||||||
static_files_dir = frontend_path / "frontend"
|
static_files_dir = frontend_path / "frontend"
|
||||||
else:
|
else:
|
||||||
static_files_dir = Path(path)
|
static_files_dir = Path(path)
|
||||||
app.mount(
|
|
||||||
"/",
|
app = create_app(static_files_dir)
|
||||||
StaticFiles(directory=static_files_dir, html=True),
|
setup_static_files(app, static_files_dir)
|
||||||
name="static",
|
|
||||||
)
|
|
||||||
options = {
|
options = {
|
||||||
"bind": f"{host}:{port}",
|
"bind": f"{host}:{port}",
|
||||||
"workers": get_number_of_workers(workers),
|
"workers": get_number_of_workers(workers),
|
||||||
|
|
@ -180,6 +179,21 @@ def serve(
|
||||||
webbrowser.open(f"http://{host}:{port}")
|
webbrowser.open(f"http://{host}:{port}")
|
||||||
|
|
||||||
|
|
||||||
|
def setup_static_files(app: FastAPI, static_files_dir: str):
|
||||||
|
"""
|
||||||
|
Setup the static files directory.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
app (FastAPI): FastAPI app.
|
||||||
|
path (str): Path to the static files directory.
|
||||||
|
"""
|
||||||
|
app.mount(
|
||||||
|
"/",
|
||||||
|
StaticFiles(directory=static_files_dir, html=True),
|
||||||
|
name="static",
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def print_banner(host, port):
|
def print_banner(host, port):
|
||||||
# console = Console()
|
# console = Console()
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,12 @@
|
||||||
from fastapi import FastAPI
|
from fastapi import FastAPI
|
||||||
|
from fastapi.responses import FileResponse
|
||||||
from fastapi.middleware.cors import CORSMiddleware
|
from fastapi.middleware.cors import CORSMiddleware
|
||||||
|
|
||||||
from langflow.api import router
|
from langflow.api import router
|
||||||
from langflow.database.base import create_db_and_tables
|
from langflow.database.base import create_db_and_tables
|
||||||
|
|
||||||
|
|
||||||
def create_app():
|
def create_app(static_path: str = "static"):
|
||||||
"""Create the FastAPI app and include the router."""
|
"""Create the FastAPI app and include the router."""
|
||||||
app = FastAPI()
|
app = FastAPI()
|
||||||
|
|
||||||
|
|
@ -17,6 +18,10 @@ def create_app():
|
||||||
def get_health():
|
def get_health():
|
||||||
return {"status": "OK"}
|
return {"status": "OK"}
|
||||||
|
|
||||||
|
@app.exception_handler(404)
|
||||||
|
async def custom_404_handler(request, __):
|
||||||
|
return FileResponse(f"{static_path}/index.html")
|
||||||
|
|
||||||
app.add_middleware(
|
app.add_middleware(
|
||||||
CORSMiddleware,
|
CORSMiddleware,
|
||||||
allow_origins=origins,
|
allow_origins=origins,
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,4 @@
|
||||||
import {
|
import { ForwardRefExoticComponent, ReactElement, ReactNode } from "react";
|
||||||
ForwardRefExoticComponent,
|
|
||||||
ReactElement,
|
|
||||||
ReactFragment,
|
|
||||||
ReactNode,
|
|
||||||
SVGProps,
|
|
||||||
} from "react";
|
|
||||||
import { NodeDataType } from "../flow/index";
|
import { NodeDataType } from "../flow/index";
|
||||||
import { typesContextType } from "../typesContext";
|
import { typesContextType } from "../typesContext";
|
||||||
export type InputComponentType = {
|
export type InputComponentType = {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue