mirror of
https://github.com/langgenius/dify.git
synced 2026-02-02 00:51:49 +08:00
Some checks are pending
autofix.ci / autofix (push) Waiting to run
Build and Push API & Web / build (api, DIFY_API_IMAGE_NAME, linux/amd64, build-api-amd64) (push) Waiting to run
Build and Push API & Web / build (api, DIFY_API_IMAGE_NAME, linux/arm64, build-api-arm64) (push) Waiting to run
Build and Push API & Web / build (web, DIFY_WEB_IMAGE_NAME, linux/amd64, build-web-amd64) (push) Waiting to run
Build and Push API & Web / build (web, DIFY_WEB_IMAGE_NAME, linux/arm64, build-web-arm64) (push) Waiting to run
Build and Push API & Web / create-manifest (api, DIFY_API_IMAGE_NAME, merge-api-images) (push) Blocked by required conditions
Build and Push API & Web / create-manifest (web, DIFY_WEB_IMAGE_NAME, merge-web-images) (push) Blocked by required conditions
Main CI Pipeline / Check Changed Files (push) Waiting to run
Main CI Pipeline / API Tests (push) Blocked by required conditions
Main CI Pipeline / Web Tests (push) Blocked by required conditions
Main CI Pipeline / Style Check (push) Waiting to run
Main CI Pipeline / VDB Tests (push) Blocked by required conditions
Main CI Pipeline / DB Migration Test (push) Blocked by required conditions
Signed-off-by: NeatGuyCoding <15627489+NeatGuyCoding@users.noreply.github.com>
46 lines
1.5 KiB
Python
46 lines
1.5 KiB
Python
from fastopenapi.routers import FlaskRouter
|
|
from flask_cors import CORS
|
|
|
|
from configs import dify_config
|
|
from controllers.fastopenapi import console_router
|
|
from dify_app import DifyApp
|
|
from extensions.ext_blueprints import AUTHENTICATED_HEADERS, EXPOSED_HEADERS
|
|
|
|
DOCS_PREFIX = "/fastopenapi"
|
|
|
|
|
|
def init_app(app: DifyApp) -> None:
|
|
docs_enabled = dify_config.SWAGGER_UI_ENABLED
|
|
docs_url = f"{DOCS_PREFIX}/docs" if docs_enabled else None
|
|
redoc_url = f"{DOCS_PREFIX}/redoc" if docs_enabled else None
|
|
openapi_url = f"{DOCS_PREFIX}/openapi.json" if docs_enabled else None
|
|
|
|
router = FlaskRouter(
|
|
app=app,
|
|
docs_url=docs_url,
|
|
redoc_url=redoc_url,
|
|
openapi_url=openapi_url,
|
|
openapi_version="3.0.0",
|
|
title="Dify API (FastOpenAPI PoC)",
|
|
version="1.0",
|
|
description="FastOpenAPI proof of concept for Dify API",
|
|
)
|
|
|
|
# Ensure route decorators are evaluated.
|
|
import controllers.console.ping as ping_module
|
|
from controllers.console import setup
|
|
|
|
_ = ping_module
|
|
_ = setup
|
|
|
|
router.include_router(console_router, prefix="/console/api")
|
|
CORS(
|
|
app,
|
|
resources={r"/console/api/.*": {"origins": dify_config.CONSOLE_CORS_ALLOW_ORIGINS}},
|
|
supports_credentials=True,
|
|
allow_headers=list(AUTHENTICATED_HEADERS),
|
|
methods=["GET", "PUT", "POST", "DELETE", "OPTIONS", "PATCH"],
|
|
expose_headers=list(EXPOSED_HEADERS),
|
|
)
|
|
app.extensions["fastopenapi"] = router
|