Skip to content
This repository has been archived by the owner on Aug 11, 2024. It is now read-only.

Commit

Permalink
Merge pull request #56 from xingren23/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
xingren23 authored Dec 28, 2023
2 parents 6cc531c + 8daa1ed commit fa54c1c
Show file tree
Hide file tree
Showing 12 changed files with 53 additions and 197 deletions.
3 changes: 0 additions & 3 deletions .streamlit/secrets.toml
Original file line number Diff line number Diff line change
@@ -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"
120 changes: 18 additions & 102 deletions Home.py
Original file line number Diff line number Diff line change
@@ -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}"
Expand All @@ -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('''
<h3>
Register user with Discord
</h3>''',
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('''
<h3>
Login failed, go
<a target="_self" href="/">Home</a>
</h3>''',
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}")
Expand All @@ -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:
Expand All @@ -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()
30 changes: 15 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
45 changes: 17 additions & 28 deletions README_zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 有什么用?
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion bin/creator_daemon.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion bin/creator_run.bat
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion bin/creator_run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Binary file removed docs/images/WechatGroup.jpg
Binary file not shown.
Binary file removed docs/images/how-it-works.png
Binary file not shown.
Binary file added docs/images/how-to-use-it.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed docs/images/wechat-xingren23.jpg
Binary file not shown.
46 changes: 0 additions & 46 deletions modules/discord_oauth.py

This file was deleted.

0 comments on commit fa54c1c

Please sign in to comment.