hatmanstack commited on
Commit
3a46b6b
·
1 Parent(s): 1ac8216

App Runner Alignment

Browse files
Files changed (1) hide show
  1. app.py +45 -38
app.py CHANGED
@@ -1,87 +1,94 @@
1
  import gradio as gr
2
  import os
3
 
4
- # Define the function for the Gradio interface (keeping the previous example)
5
- def greet(name):
6
- """Returns a greeting string for the given name."""
7
- if not name:
8
- return "Hello!"
9
- return f"Hello, {name}!"
10
-
11
- # CSS extracted and adapted from the FastAPI app's HTML
12
- # We target specific elements or use broader selectors for Gradio
13
  custom_css = """
14
  body, .gradio-container {
15
  background-color: #333 !important; /* Charcoal background */
16
  color: #fff !important; /* White text color */
17
  font-family: Arial, sans-serif !important;
18
  margin: 0 !important;
 
19
  }
20
- /* Add padding to the main container */
21
  .gradio-container {
22
  padding: 20px !important;
23
  }
24
 
25
- /* Style the specific Markdown h1 using its generated ID or a custom one */
26
- /* Let's wrap the markdown in a div with an ID for easier targeting */
27
- #float-title h1 {
28
- font-size: 2em;
29
- text-align: center;
30
- margin-bottom: 20px; /* Add some spacing */
31
- transition: font-size 0.3s ease;
 
 
 
32
  }
33
- #float-title h1:hover {
34
- font-size: 3em; /* Hover effect */
 
 
 
 
 
 
 
35
  }
 
 
36
  #float-title a {
37
- color: #EA3C53 !important; /* Link color */
 
38
  text-decoration: none !important;
 
 
 
 
39
  }
 
 
40
  #float-title a:hover {
 
41
  text-decoration: none !important;
42
  }
43
 
44
- /* Style other Gradio elements for better contrast/consistency */
45
  label, .gr-button {
46
- color: #fff !important; /* Ensure labels and buttons use white text */
47
  font-family: Arial, sans-serif !important;
48
  }
49
  .gr-button {
50
- background-color: #555 !important; /* Darker button background */
51
  border: 1px solid #777 !important;
52
  }
53
  .gr-button:hover {
54
- background-color: #EA3C53 !important; /* Use link color on hover */
55
  border: 1px solid #EA3C53 !important;
56
  }
57
  textarea, input[type=text] {
58
- background-color: #444 !important; /* Darker input fields */
59
  color: #fff !important;
60
  border: 1px solid #666 !important;
61
  }
62
-
63
  """
64
 
65
  # Create the Gradio interface with custom CSS
66
- # theme='dark' can also help set a base dark mode
67
  with gr.Blocks(css=custom_css, theme=gr.themes.Default(primary_hue=gr.themes.colors.red, secondary_hue=gr.themes.colors.pink)) as demo:
68
 
69
- # Add the styled title using Markdown wrapped in a div with an ID
70
- with gr.Row():
71
- with gr.Column(): # Use column to center potentially
72
- gr.HTML("""
73
- <div id="float-title">
74
- <h1><a href="https://iu2ggxd43p.us-west-2.awsapprunner.com//">AWS Nova Canvas</a></h1>
75
- <h3>App Runner Deployment</h3>
76
- </div>
77
- """) # Use HTML component for better control if needed
78
 
79
-
80
 
81
 
82
  # Launch the Gradio app
83
  if __name__ == "__main__":
84
  server_name = os.getenv("GRADIO_SERVER_NAME", "0.0.0.0")
85
  server_port = int(os.getenv("GRADIO_SERVER_PORT", 7860))
86
- # Set share=False for deployment environments like App Runner
87
  demo.launch(server_name=server_name, server_port=server_port, share=False)
 
1
  import gradio as gr
2
  import os
3
 
4
+ # Revised CSS
 
 
 
 
 
 
 
 
5
  custom_css = """
6
  body, .gradio-container {
7
  background-color: #333 !important; /* Charcoal background */
8
  color: #fff !important; /* White text color */
9
  font-family: Arial, sans-serif !important;
10
  margin: 0 !important;
11
+ overflow-x: hidden !important; /* Prevent horizontal scrollbar on main container/body */
12
  }
 
13
  .gradio-container {
14
  padding: 20px !important;
15
  }
16
 
17
+ /* Container for the title elements using Flexbox */
18
+ #float-title {
19
+ display: flex; /* Use flexbox for layout */
20
+ justify-content: center; /* Center the items horizontally */
21
+ align-items: center; /* Center the items vertically */
22
+ width: 100%; /* Take full width to allow centering */
23
+ margin-top: 50px; /* Add vertical spacing */
24
+ margin-bottom: 30px;
25
+ min-height: 4em; /* Give it some height for vertical centering */
26
+ /* overflow: hidden; /* Avoid this if possible as it might clip */
27
  }
28
+
29
+ /* Style for the static text part */
30
+ #float-title .static-text {
31
+ font-size: 2em; /* Set base size */
32
+ color: #fff; /* Ensure text color */
33
+ margin-right: 15px; /* Increased space between text and link */
34
+ white-space: nowrap; /* Prevent wrapping */
35
+ position: relative; /* Helps with potential stacking/overlap issues */
36
+ z-index: 1; /* Try to keep text above the link background */
37
  }
38
+
39
+ /* Style for the link part */
40
  #float-title a {
41
+ font-size: 2em; /* Set base size */
42
+ color: #EA3C53 !important;
43
  text-decoration: none !important;
44
+ display: inline-block; /* Necessary for transform to work */
45
+ transition: transform 0.3s ease; /* Smooth scaling transition */
46
+ transform-origin: left center; /* Scale expansion biased to the right */
47
+ white-space: nowrap; /* Prevent wrapping */
48
  }
49
+
50
+ /* Apply scaling effect only to the link on hover */
51
  #float-title a:hover {
52
+ transform: scale(1.3); /* Reduced scale factor */
53
  text-decoration: none !important;
54
  }
55
 
56
+ /* Keep other styles */
57
  label, .gr-button {
58
+ color: #fff !important;
59
  font-family: Arial, sans-serif !important;
60
  }
61
  .gr-button {
62
+ background-color: #555 !important;
63
  border: 1px solid #777 !important;
64
  }
65
  .gr-button:hover {
66
+ background-color: #EA3C53 !important;
67
  border: 1px solid #EA3C53 !important;
68
  }
69
  textarea, input[type=text] {
70
+ background-color: #444 !important;
71
  color: #fff !important;
72
  border: 1px solid #666 !important;
73
  }
 
74
  """
75
 
76
  # Create the Gradio interface with custom CSS
 
77
  with gr.Blocks(css=custom_css, theme=gr.themes.Default(primary_hue=gr.themes.colors.red, secondary_hue=gr.themes.colors.pink)) as demo:
78
 
79
+ # Revised HTML structure within gr.HTML
80
+ gr.HTML("""
81
+ <div id="float-title">
82
+ <span class="static-text">App Runner Deployment >> </span>
83
+ <a href="https://iu2ggxd43p.us-west-2.awsapprunner.com">AWS Nova Canvas</a>
84
+ </div>
85
+ """)
 
 
86
 
87
+
88
 
89
 
90
  # Launch the Gradio app
91
  if __name__ == "__main__":
92
  server_name = os.getenv("GRADIO_SERVER_NAME", "0.0.0.0")
93
  server_port = int(os.getenv("GRADIO_SERVER_PORT", 7860))
 
94
  demo.launch(server_name=server_name, server_port=server_port, share=False)