Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add app started callback #3982

Merged
merged 2 commits into from
Nov 1, 2022

Conversation

MaikoTan
Copy link
Contributor

@MaikoTan MaikoTan commented Oct 30, 2022

This is useful like when you want to add a custom API route from extensions or do some post-processing for FastAPI class.

not sure if this available...
@Interpause
Copy link

If mounting custom APIs, what would the recommended path be?

I am currently thinking /sdapi/ext/<repo_name>

@MaikoTan
Copy link
Contributor Author

MaikoTan commented Nov 2, 2022

If mounting custom APIs, what would the recommended path be?

I am currently thinking /sdapi/ext/<repo_name>

I think you can use any custom paths that matches your own, as long as not to override existing ones.
For example, I have an app named dream, so I registered my custom API like this:

from fastapi import FastAPI
import gradio as gr

import modules.script_callbacks as script_callbacks

def dream(demo: gr.Blocks, app: FastAPI):
    @app.get("/dream/start")
    async def start_dream():
        # ...

    @app.get("/dream/stop")
    async def stop_dream():
        # ...

script_callbacks.on_app_started(dream)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants