diff --git a/.streamlit/secrets.toml b/.streamlit/secrets.toml index 94422f7..1a98324 100644 --- a/.streamlit/secrets.toml +++ b/.streamlit/secrets.toml @@ -1,8 +1,5 @@ COMFYFLOW_API_URL="https://api.comfyflow.app" DISCORD_CLIENT_ID="1163088920305737728" -DISCORD_CLIENT_SECRET="hdqis8gZ9YVvvM-qxAbYApd6ai40nBlk" - -# mode: Creator/Studio/Explore [connections.comfyflow_db] url = "sqlite:///comfyflow.db" \ No newline at end of file diff --git a/Home.py b/Home.py index 3b3e7ec..181e468 100644 --- a/Home.py +++ b/Home.py @@ -1,41 +1,13 @@ import streamlit as st import requests +import os from loguru import logger from streamlit_authenticator.exceptions import RegisterError from streamlit_extras.row import row from modules import page from modules.authenticate import MyAuthenticate -from modules import discord_oauth from modules.authenticate import Validator -def register_user(username: str, name: str, password: str, email: str, invite_code: str): - logger.debug(f"register user, {username}, {name}, {password}, {email}") - validator = Validator() - # register credentials to comfyflowapp - if not validator.validate_username(username): - raise RegisterError('Username is not valid') - if not validator.validate_name(name): - raise RegisterError('Name is not valid') - if not validator.validate_email(email): - raise RegisterError('Email is not valid') - if not len(password) >= 8: - raise RegisterError('Password is not valid, length > 8') - - # register user - register_json = { - "nickname": name, - "username": username, - "password": password, - "email": email, - "invite_code": invite_code - } - comfyflow_url = st.secrets['COMFYFLOW_API_URL'] - ret = requests.post(f"{comfyflow_url}/api/user/register", json=register_json) - if ret.status_code != 200: - raise RegisterError(f"register user error, {ret.text}") - else: - logger.info(f"register user success, {ret.json()}") - st.success(f"Register user success, {username}") def gen_invite_code(source: str, uid: str): invate_code = f"oauth_{source}_{uid}" @@ -46,58 +18,28 @@ def back_home_signup(): logger.info("back home login") -def discord_callback(user_data): - with header_button: - st.button("Login", key="home_button", on_click=back_home_signup) - - st.write(''' -

- Register user with Discord -

''', - unsafe_allow_html=True - ) - with st.container(): - if user_data: - register_user_form = st.form('Register user with Discord') - # register_user_form.subheader(form_name) - new_email = register_user_form.text_input('Email', value=user_data['email'], help='Please enter a valid email address') - new_username = register_user_form.text_input('Username', value=user_data['username'], help='Please enter a username') - new_name = register_user_form.text_input('Name', value=user_data['username'],help='Please enter your name') - - new_password = register_user_form.text_input('Password', type='password') - new_password_repeat = register_user_form.text_input('Repeat password', type='password') - - invite_code = gen_invite_code("discord", user_data['id']) - - if register_user_form.form_submit_button('Register'): - logger.debug(f"register user, {new_username}, {new_name}, {new_password}, {new_email}") - if len(new_email) and len(new_username) and len(new_name) and len(new_password) > 0: - if new_password == new_password_repeat: - register_user(new_username, new_name, new_password, new_email, invite_code) - else: - raise RegisterError('Passwords do not match') - else: - raise RegisterError('Please enter an email, username, name, and password') - else: - st.experimental_set_query_params() - st.write(''' -

- Login failed, go - Home -

''', - unsafe_allow_html=True - ) +page.init_env_default() +page.page_init(layout="centered") +with st.container(): + header_row = row([0.87, 0.13], vertical_align="bottom") + header_row.title(""" + Welcome to ComfyFlowApp + From comfyui workflow to web application in seconds, and share with others. + """) + header_button = header_row.empty() -def home(): auth_instance = MyAuthenticate("comfyflow_token", "ComfyFlowApp: Load ComfyUI workflow as webapp in seconds.") if not st.session_state['authentication_status']: with header_button: - signup_url = discord_oauth.gen_authorization_url() + client_id = os.getenv('DISCORD_CLIENT_ID') + redirect_uri = os.getenv('DISCORD_REDIRECT_URI') + signup_url = f"https://discord.com/oauth2/authorize?client_id={client_id}&scope=identify+email&redirect_uri={redirect_uri}&response_type=code" st.link_button("Sign Up", type="primary", url=signup_url, help="Sign up with Discord") with st.container(): try: + st.markdown("ComfyFlowApp offers an in-built test account(username: demo) with the credentials(password: comfyflowapp). For an enhanced user experience, please sign up your account at https://comfyflow.app.") auth_instance.login("Login to ComfyFlowApp") except Exception as e: st.error(f"Login failed, {e}") @@ -113,11 +55,11 @@ def home(): st.markdown(f"Hello, {name}({username}) :smile:") st.markdown(""" - ## 📌 What is ComfyFlowApp? + ### 📌 What is ComfyFlowApp? ComfyFlowApp is an extension tool for ComfyUI, making it easy to develop a user-friendly web application from a ComfyUI workflow and share it with others. """) st.markdown(""" - ### Why You Need ComfyFlowApp? + ### 📌 Why You Need ComfyFlowApp? ComfyFlowApp helps creator to develop a web app from comfyui workflow in seconds. If you need to share workflows developed in ComfyUI with other users, ComfyFlowApp can significantly lower the barrier for others to use your workflows: @@ -129,35 +71,9 @@ def home(): """) st.markdown(""" - ### Typical Use Cases - 1) Studio or Internal Business Collaboration - 2) Professional Creators or Teams, Developing and Sharing Applications with a Wider Audience + ### 📌 Use Cases """) + st.image("./docs/images/how-to-use-it.png", use_column_width=True) st.markdown(""" :point_right: Follow the repo [ComfyFlowApp](https://github.com/xingren23/ComfyFlowApp) to get the latest updates. - - [!["Buy Me A Coffee"](https://www.buymeacoffee.com/assets/img/custom_images/orange_img.png)](https://www.buymeacoffee.com/comfyflow) """) - -page.init_env_default() -page.page_init(layout="centered") - -with st.container(): - header_row = row([0.85, 0.15], vertical_align="bottom") - header_row.title(""" - Welcome to ComfyFlowApp - From comfyui workflow to web application in seconds, and share with others. - """) - header_button = header_row.empty() - - code = st.experimental_get_query_params().get('code') - if code: - user_data = discord_oauth.get_user_data(code[0]) - st.session_state['user_data'] = user_data - st.experimental_set_query_params() - - if 'user_data' in st.session_state: - user_data = st.session_state['user_data'] - discord_callback(user_data=user_data) - else: - home() diff --git a/README.md b/README.md index 9872ba8..041ccca 100644 --- a/README.md +++ b/README.md @@ -28,35 +28,35 @@ If you need to share workflows developed in ComfyUI with other users, ComfyFlowA **In summary, ComfyFlowApp make comfyui workflow easy to use.** -### How Does ComfyFlowApp Work? -ComfyFlowApp: Users (also creators) can develop a web application from the ComfyUI workflow in seconds, and share it with other users. +### Use Cases -::: tip +![How-to-use-it](./docs/images/how-to-use-it.png) -[comfyflow.app](https://comfyflow.app/) is a platform for uploading and distributing ComfyUI web applications. +**1. For internal corporate collaboration** -::: +* Creators develop workflows in ComfyUI and productize these workflows into web applications using ComfyFlowApp. +* Users access and utilize the workflow applications through ComfyFlowApp to enhance work efficiency. -The workflow is shown below: -![How-it-works](./docs/images/how-it-works.png) +**2. For remote corporate collaboration** -### Typical Use Cases +* Deploy ComfyUI and ComfyFlowApp to cloud services like RunPod/Vast.ai/AWS, and map the server ports for public access, such as https://{POD_ID}-{INTERNAL_PORT}.proxy.runpod.net. +* Creators develop workflows in ComfyUI and productize these workflows into web applications using ComfyFlowApp. +* Users access and utilize these workflow applications through ComfyFlowApp to enhance work efficiency. -1. Studio or Internal Business Collaboration +**3. For SaaS services** - In scenarios where a studio or internal business needs collaborative work division and not everyone needs to understand AI, various models, and workflow construction, a typical collaboration scenario involves one or a few developers building an AI application within ComfyUI, achieving satisfactory results, and saving the workflow. Then, developers use ComfyFlowApp's Creator tool to convert the workflow into a web application, hiding irrelevant fine-tuning parameters, making the application simple and easy to use. Developers can then share the application's address with other users within the studio or the company, who can access the deployed application through the shared address. - -2. Professional Creators or Teams, Developing and Sharing Applications with a Wider Audience - - Professional creators or teams can use ComfyUI tools to develop valuable applications, but the usability of ComfyUI may be too high for the normal user. By using ComfyFlowApp to transform a workflow into an application suitable for a broader audience, developers can create more value. This process typically involves developers creating a workflow in ComfyUI, achieving satisfactory results, and saving the workflow. Developers then use ComfyFlowApp's Creator tool to convert the workflow into a web application, hiding irrelevant fine-tuning parameters, and making the application easy to use. After that, developers can publish the application in an app store, allowing other users to discover and download the application and run it locally. +* ComfyFlowApp provides an application hosting environment, including the model and ComfyUI extension nodes. +* Creators publish their workflow applications to ComfyFlowApp. +* Users subscribe to use the workflow applications. **Follow the repo to get the latest updates.** -[!["Buy Me A Coffee"](https://www.buymeacoffee.com/assets/img/custom_images/orange_img.png)](https://www.buymeacoffee.com/comfyflow) ### 📌 Quick Start +ComfyFlowApp offers an in-built test account(username: demo) with the credentials(password: comfyflowapp). For an enhanced user experience, please sign up your account at https://comfyflow.app. + ```bash # download project git clone https://github.com/xingren23/ComfyFlowApp diff --git a/README_zh-CN.md b/README_zh-CN.md index 6deee83..7846d2d 100644 --- a/README_zh-CN.md +++ b/README_zh-CN.md @@ -4,9 +4,10 @@ ## ComfyFlowApp 是什么? -ComfyFlowApp 是一个 ComfyUI 的扩展工具, 可以轻松从 ComfyUI 的工作流开发出一个简单易用的应用,降低 ComfyUI 的使用门槛。 +ComfyFlowApp 是一个 ComfyUI 的扩展工具, 可以轻松从 ComfyUI 工作流开发出一个简单易用的 Web 应用,降低 ComfyUI 的使用门槛。 如下图所示,将一个人像修复的工作流开发成一个 ComfyFlowApp 应用。 ![图1](docs/images/demo-workflow.png) + ![图2](docs/images/demo-webapp.png) ### ComfyFlowApp 有什么用? @@ -24,45 +25,33 @@ ComfyFlowApp 是一个 ComfyUI 的扩展工具, 可以轻松从 ComfyUI 的工 **总结,ComfyFlowApp 帮助工作流开发者简化工作流的使用难度,用户只需要像普通应用一样使用即可。** -### ComfyFlowApp 的运行方式 - -ComfyFlowApp :用户(也是创作者)可以将 ComfyUI 工作流转换为一个 Web 应用,并分享给其他用户使用。 - -::: tip - -[comfyflow.app](https://comfyflow.app/) 是一个上传分发 ComfyUI Web 应用的平台。 +### 使用场景 -::: +![How-to-use-it](./docs/images/how-to-use-it.png) -工作流如下图所示: -![How-it-works](./docs/images/how-it-works.png) +**1. 企业内部协作** -### 典型使用场景 +* 创作者在ComfyUI中开发工作流,并使用ComfyFlowApp将这些工作流产品化为Web应用。 +* 使用者通过ComfyFlowApp使用这些工作流应用,以提高工作效率。 -**1)工作室或企业内部的分工协作** +**2. 远程企业协作** -工作室或企业内部处于分工协作的需求,并不要求每个人都懂 AI,懂各种模型,懂工作流搭建,典型的协作场景:一个人或几个人来构建 AI 应用,其他用户直接使用。 +* 将ComfyUI和ComfyFlowApp部署到像RunPod/Vast.ai/AWS这样的云服务上,并将服务器端口映射为公网访问,例如https://{POD_ID}-{INTERNAL_PORT}.proxy.runpod.net。 +* 创作者在ComfyUI中开发工作流,并使用ComfyFlowApp将这些工作流产品化为Web应用。 +* 使用者通过ComfyFlowApp使用这些工作流应用,以提高工作效率。 -1. 开发者在 ComfyUI 中开发工作流,测试出满意的效果,保存工作流; -2. 开发者使用 ComfyFlowApp 工具 Creator,从工作流转换为一个 Web 应用,隐藏无关的细节参数,让应用简单易用; -3. 开发者启动应用,并将地址分享给工作室或企业内部的用户使用; -4. 其他用户通过分享的应用地址访问开发者部署的应用; +**3. SaaS服务** -**2)专业创造者或团队,开发并将应用分享给更多人使用** - -通过 ComfyUI 工具,专业的创作者或团队可以开发出很有价值的应用,但 ComfyUI 对普通来说使用门槛太高;使用 ComfyFlowApp 将工作流开发成一个面向更大众用户的应用,可以创造更大的价值。 - -1. 开发者在 ComfyUI 中开发工作流,测试出满意的效果,保存工作流; -2. 开发者使用 ComfyFlowApp 工具 Creator,从工作流转换为一个 Web 应用,隐藏无关的细节参数,让应用简单易用; -3. 开发者将应用发布的应用市场; -4. 其他用户从应用市场发现并下载应用,本地运行应用; +* ComfyFlowApp提供应用托管运行环境,包括模型和ComfyUI扩展节点。 +* 创作者将其工作流应用发布到ComfyFlowApp。 +* 用户订阅使用这些工作流应用。 关注本项目,获取最新动态。 -[!["Buy Me A Coffee"](https://www.buymeacoffee.com/assets/img/custom_images/orange_img.png)](https://www.buymeacoffee.com/comfyflow) - ### 快速开始 +ComfyFlowApp 提供了一个测试账号:demo 密码:comfyflowapp,为了更好的用户体验,你可以在 https://comfyflow.app 注册自己的账号。 + ```bash # 下载项目 git clone https://github.com/xingren23/ComfyFlowApp diff --git a/bin/creator_daemon.sh b/bin/creator_daemon.sh index 257e00e..c3c87d3 100644 --- a/bin/creator_daemon.sh +++ b/bin/creator_daemon.sh @@ -15,7 +15,7 @@ export COMFYFLOW_API_URL=https://api.comfyflow.app # set COMFYUI_SERVER_ADDR to comfyui server addr export COMFYUI_SERVER_ADDR=http://localhost:8188 # set discord callback url -export DISCORD_REDIRECT_URI=http://localhost:8501 +export DISCORD_REDIRECT_URI=https://comfyflow.app # set MODE to Creator export MODE=Creator diff --git a/bin/creator_run.bat b/bin/creator_run.bat index b0499fb..5f94b32 100644 --- a/bin/creator_run.bat +++ b/bin/creator_run.bat @@ -15,7 +15,7 @@ set COMFYFLOW_API_URL=https://api.comfyflow.app :: set COMFYUI_SERVER_ADDR to localhost:8188 set COMFYUI_SERVER_ADDR=http://localhost:8188 :: set discord callback url -set DISCORD_REDIRECT_URI=http://localhost:8501 +set DISCORD_REDIRECT_URI=https://comfyflow.app :: set MODE set MODE=Creator diff --git a/bin/creator_run.sh b/bin/creator_run.sh index 126a4ce..a178acc 100644 --- a/bin/creator_run.sh +++ b/bin/creator_run.sh @@ -15,7 +15,7 @@ export COMFYFLOW_API_URL=https://api.comfyflow.app # set COMFYUI_SERVER_ADDR to comfyui server addr export COMFYUI_SERVER_ADDR=http://localhost:8188 # set discord callback url -export DISCORD_REDIRECT_URI=http://localhost:8501 +export DISCORD_REDIRECT_URI=https://comfyflow.app # set MODE to Creator export MODE=Creator diff --git a/docs/images/WechatGroup.jpg b/docs/images/WechatGroup.jpg deleted file mode 100644 index 912f202..0000000 Binary files a/docs/images/WechatGroup.jpg and /dev/null differ diff --git a/docs/images/how-it-works.png b/docs/images/how-it-works.png deleted file mode 100644 index 5846f77..0000000 Binary files a/docs/images/how-it-works.png and /dev/null differ diff --git a/docs/images/how-to-use-it.png b/docs/images/how-to-use-it.png new file mode 100644 index 0000000..34ac805 Binary files /dev/null and b/docs/images/how-to-use-it.png differ diff --git a/docs/images/wechat-xingren23.jpg b/docs/images/wechat-xingren23.jpg deleted file mode 100644 index ff299d0..0000000 Binary files a/docs/images/wechat-xingren23.jpg and /dev/null differ diff --git a/modules/discord_oauth.py b/modules/discord_oauth.py deleted file mode 100644 index c6c7077..0000000 --- a/modules/discord_oauth.py +++ /dev/null @@ -1,46 +0,0 @@ -import os -from loguru import logger - -import streamlit as st - -client_id = os.getenv('DISCORD_CLIENT_ID') -client_secret = os.getenv('DISCORD_CLIENT_SECRET') -redirect_uri = os.getenv('DISCORD_REDIRECT_URI') - - -@st.cache_resource -def get_client(): - try: - import discordoauth2 - client = discordoauth2.Client(client_id, secret=client_secret, redirect=redirect_uri) - return client - except Exception as e: - logger.error(f"get_client error: {e}") - return None - - -@st.cache_data(ttl=60 * 60) -def gen_authorization_url(): - client = get_client() - if client: - authorization_url = client.generate_uri(scope=["identify", "email"]) - logger.debug(f"authorization_url: {authorization_url}") - return authorization_url - else: - authorization_url = f"https://discord.com/oauth2/authorize?client_id={client_id}&scope=identify+email&redirect_uri={redirect_uri}&response_type=code" - logger.warning(f"discordoauth2 is none, default authorization_url : {authorization_url}") - return authorization_url - - -def get_user_data(code): - try: - client = get_client() - if client: - access = client.exchange_code(code) - user_data = access.fetch_identify() - logger.debug(f"user_data: {user_data}") - return user_data - except Exception as e: - logger.error(f"get_user_data error: {e}") - return None -