fantaxy commited on
Commit
682535d
ยท
verified ยท
1 Parent(s): a194516

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +18 -15
app.py CHANGED
@@ -16,18 +16,26 @@ api_client = Client("http://211.233.58.202:7960/")
16
 
17
  # Notion ํด๋ผ์ด์–ธํŠธ ์„ค์ •
18
  NOTION_TOKEN = os.getenv("NOTION_TOKEN")
19
- NOTION_DATABASE_ID = "b4ba17da43cd4bedb5482ef10e5ffc8d"
20
  notion = NotionClient(auth=NOTION_TOKEN)
21
 
22
  def add_to_notion(prompt, image_path):
23
- now = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
24
-
25
- new_page = {
26
- "Prompt": {"title": [{"text": {"content": prompt}}]},
27
- "Image": {"url": image_path},
28
- "Date": {"date": {"start": now}}
29
- }
30
- notion.pages.create(parent={"database_id": NOTION_DATABASE_ID}, properties=new_page)
 
 
 
 
 
 
 
 
31
 
32
  def respond(message, seed, randomize_seed, width, height, guidance_scale, num_inference_steps):
33
  logging.info(f"Received message: {message}, seed: {seed}, randomize_seed: {randomize_seed}, "
@@ -63,14 +71,13 @@ def respond(message, seed, randomize_seed, width, height, guidance_scale, num_in
63
  def use_prompt(prompt):
64
  return prompt
65
 
66
-
67
-
68
  css = """
69
  footer {
70
  visibility: hidden;
71
  }
72
  """
73
 
 
74
  # ์ด๋ฏธ์ง€ ์ƒ์„ฑ์„ ์œ„ํ•œ ์˜ˆ์ œ ํ”„๋กฌํ”„ํŠธ
75
  examples = [
76
  ["A glamorous young woman with long, wavy blonde hair and smokey eye makeup, posing in a luxury hotel room. Sheโ€™s wearing a sparkly gold cocktail dress and holding up a white card with 'openfree.ai' written on it in elegant calligraphy. Soft, warm lighting creates a luxurious atmosphere. ", "q1.webp"],
@@ -95,12 +102,8 @@ examples = [
95
  ["A fantasy map of a fictional world, with detailed terrain and cities.", "q19.webp"]
96
  ]
97
 
98
- def use_prompt(prompt):
99
- return prompt
100
 
101
  with gr.Blocks(theme="Nymbo/Nymbo_Theme", css=css) as demo:
102
-
103
-
104
  with gr.Row():
105
  input_text = gr.Textbox(label="Enter your prompt for image generation")
106
  output_image = gr.Image(label="Generated Image")
 
16
 
17
  # Notion ํด๋ผ์ด์–ธํŠธ ์„ค์ •
18
  NOTION_TOKEN = os.getenv("NOTION_TOKEN")
19
+ NOTION_DATABASE_ID = "88c9bdadcb2044129af77d5932e1a82a"
20
  notion = NotionClient(auth=NOTION_TOKEN)
21
 
22
  def add_to_notion(prompt, image_path):
23
+ try:
24
+ now = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
25
+
26
+ new_page = {
27
+ "Prompt": {"title": [{"text": {"content": prompt}}]},
28
+ "Image": {"url": image_path},
29
+ "Date": {"date": {"start": now}}
30
+ }
31
+ response = notion.pages.create(parent={"database_id": NOTION_DATABASE_ID}, properties=new_page)
32
+ logging.info(f"Successfully added to Notion: {response}")
33
+ except Exception as e:
34
+ logging.error(f"Error adding to Notion: {str(e)}")
35
+ logging.error(f"Database ID: {NOTION_DATABASE_ID}")
36
+ logging.error(f"Prompt: {prompt}")
37
+ logging.error(f"Image path: {image_path}")
38
+ raise
39
 
40
  def respond(message, seed, randomize_seed, width, height, guidance_scale, num_inference_steps):
41
  logging.info(f"Received message: {message}, seed: {seed}, randomize_seed: {randomize_seed}, "
 
71
  def use_prompt(prompt):
72
  return prompt
73
 
 
 
74
  css = """
75
  footer {
76
  visibility: hidden;
77
  }
78
  """
79
 
80
+
81
  # ์ด๋ฏธ์ง€ ์ƒ์„ฑ์„ ์œ„ํ•œ ์˜ˆ์ œ ํ”„๋กฌํ”„ํŠธ
82
  examples = [
83
  ["A glamorous young woman with long, wavy blonde hair and smokey eye makeup, posing in a luxury hotel room. Sheโ€™s wearing a sparkly gold cocktail dress and holding up a white card with 'openfree.ai' written on it in elegant calligraphy. Soft, warm lighting creates a luxurious atmosphere. ", "q1.webp"],
 
102
  ["A fantasy map of a fictional world, with detailed terrain and cities.", "q19.webp"]
103
  ]
104
 
 
 
105
 
106
  with gr.Blocks(theme="Nymbo/Nymbo_Theme", css=css) as demo:
 
 
107
  with gr.Row():
108
  input_text = gr.Textbox(label="Enter your prompt for image generation")
109
  output_image = gr.Image(label="Generated Image")