MCP_test / app.py
PD03's picture
Update app.py
ef36ca7 verified
raw
history blame
11.9 kB
import gradio as gr
def submit_action(*inputs):
return (
f"<div style='padding: 20px; background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); border-radius: 16px; margin-top: 20px;'>"
f"<div style='color: white; font-size: 1.3em; font-weight: 600; margin-bottom: 8px;'>πŸŽ‰ Registration Submitted Successfully!</div>"
f"<div style='color: rgba(255,255,255,0.9); font-size: 1.1em; margin-bottom: 16px;'>Welcome aboard, <span style='font-weight: 600;'>{inputs[0]}</span>!</div>"
f"<div style='display: flex; gap: 12px; flex-wrap: wrap;'>"
f"<span style='background: rgba(34, 197, 94, 0.2); color: #22c55e; padding: 8px 16px; border-radius: 24px; font-size: 0.9em; font-weight: 500; border: 1px solid rgba(34, 197, 94, 0.3);'>βœ“ Verified</span>"
f"<span style='background: rgba(245, 158, 11, 0.2); color: #f59e0b; padding: 8px 16px; border-radius: 24px; font-size: 0.9em; font-weight: 500; border: 1px solid rgba(245, 158, 11, 0.3);'>⏳ Approval Pending</span>"
f"</div>"
f"</div>"
)
with gr.Blocks(css="""
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');
* {
font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif !important;
}
.gradio-container {
background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
min-height: 100vh;
padding: 2rem 1rem;
}
.main-card {
max-width: 1100px;
margin: 0 auto;
background: rgba(255, 255, 255, 0.95);
backdrop-filter: blur(20px);
border-radius: 24px;
box-shadow: 0 32px 64px rgba(0, 0, 0, 0.1);
padding: 0;
border: 1px solid rgba(255, 255, 255, 0.2);
overflow: hidden;
}
.header-section {
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
padding: 40px 48px;
color: white;
position: relative;
overflow: hidden;
}
.header-section::before {
content: '';
position: absolute;
top: -50%;
right: -50%;
width: 200%;
height: 200%;
background: radial-gradient(circle, rgba(255,255,255,0.1) 0%, transparent 70%);
animation: float 6s ease-in-out infinite;
}
@keyframes float {
0%, 100% { transform: translateY(0px) rotate(0deg); }
50% { transform: translateY(-20px) rotate(180deg); }
}
.step-indicator {
display: flex;
align-items: center;
gap: 16px;
margin-bottom: 32px;
position: relative;
z-index: 1;
}
.step {
display: flex;
align-items: center;
gap: 8px;
padding: 8px 16px;
border-radius: 20px;
font-size: 0.9em;
font-weight: 500;
transition: all 0.3s ease;
}
.step.active {
background: rgba(255, 255, 255, 0.2);
color: white;
font-weight: 600;
}
.step.inactive {
color: rgba(255, 255, 255, 0.6);
}
.step-arrow {
color: rgba(255, 255, 255, 0.4);
font-size: 1.2em;
}
.main-title {
font-size: 2.5em;
font-weight: 800;
margin-bottom: 8px;
position: relative;
z-index: 1;
text-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}
.subtitle {
font-size: 1.2em;
color: rgba(255, 255, 255, 0.9);
font-weight: 400;
position: relative;
z-index: 1;
}
.form-content {
padding: 48px;
}
.section-title {
font-size: 1.3em;
font-weight: 700;
color: #1f2937;
margin-bottom: 24px;
margin-top: 40px;
position: relative;
padding-left: 16px;
}
.section-title::before {
content: '';
position: absolute;
left: 0;
top: 50%;
transform: translateY(-50%);
width: 4px;
height: 24px;
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
border-radius: 2px;
}
.section-title:first-of-type {
margin-top: 0;
}
.input-group {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 32px;
margin-bottom: 32px;
}
.input-wrapper {
position: relative;
}
.verification-badge {
display: inline-flex;
align-items: center;
gap: 6px;
padding: 6px 12px;
border-radius: 20px;
font-size: 0.85em;
font-weight: 500;
margin-left: 8px;
transition: all 0.3s ease;
}
.badge-verified {
background: linear-gradient(135deg, #d1fae5 0%, #a7f3d0 100%);
color: #065f46;
border: 1px solid #a7f3d0;
}
.badge-pending {
background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
color: #92400e;
border: 1px solid #fde68a;
}
.status-section {
background: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 100%);
padding: 24px;
border-radius: 16px;
margin: 24px 0;
border: 1px solid #e2e8f0;
}
.status-badges {
display: flex;
gap: 12px;
flex-wrap: wrap;
margin-bottom: 16px;
}
.access-level {
color: #64748b;
font-size: 0.95em;
font-weight: 500;
}
.summary-table {
width: 100%;
border-collapse: collapse;
margin-top: 16px;
}
.summary-table td {
padding: 12px 0;
border-bottom: 1px solid #e2e8f0;
font-size: 0.95em;
}
.summary-table td:first-child {
color: #64748b;
font-weight: 500;
width: 180px;
}
.summary-table td:last-child {
color: #1f2937;
font-weight: 600;
}
.submit-btn {
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
color: white;
border: none;
padding: 16px 32px;
border-radius: 12px;
font-size: 1.1em;
font-weight: 600;
cursor: pointer;
transition: all 0.3s ease;
box-shadow: 0 8px 24px rgba(102, 126, 234, 0.3);
margin-top: 32px;
width: 100%;
}
.submit-btn:hover {
transform: translateY(-2px);
box-shadow: 0 12px 32px rgba(102, 126, 234, 0.4);
}
/* Gradio component styling */
.gradio-textbox, .gradio-dropdown {
border-radius: 12px !important;
border: 2px solid #e2e8f0 !important;
transition: all 0.3s ease !important;
}
.gradio-textbox:focus, .gradio-dropdown:focus {
border-color: #667eea !important;
box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1) !important;
}
.gradio-textbox input, .gradio-dropdown select {
font-size: 0.95em !important;
padding: 12px 16px !important;
}
label {
font-weight: 600 !important;
color: #374151 !important;
margin-bottom: 8px !important;
font-size: 0.9em !important;
}
@media (max-width: 768px) {
.main-card {
margin: 0 16px;
border-radius: 16px;
}
.header-section {
padding: 32px 24px;
}
.form-content {
padding: 32px 24px;
}
.input-group {
grid-template-columns: 1fr;
gap: 24px;
}
.main-title {
font-size: 2em;
}
.step-indicator {
flex-wrap: wrap;
gap: 8px;
}
}
""") as demo:
with gr.Group(elem_classes="main-card"):
# Header Section
gr.HTML("""
<div class='header-section'>
<div class='step-indicator'>
<div class='step active'>
<span>1</span>
<span>Onboarding</span>
</div>
<div class='step-arrow'>β†’</div>
<div class='step inactive'>
<span>2</span>
<span>Documents</span>
</div>
<div class='step-arrow'>β†’</div>
<div class='step inactive'>
<span>3</span>
<span>Complete</span>
</div>
</div>
<div class='main-title'>Business Partner Registration</div>
<div class='subtitle'>Auto Digital Public Infrastructure Platform</div>
</div>
""")
# Form Content
with gr.Group(elem_classes="form-content"):
# Identification Section
gr.HTML("<div class='section-title'>🏒 Company Identification</div>")
with gr.Row(elem_classes="input-group"):
legal_name = gr.Textbox(label="Legal Entity Name", value="ABC Enterprises")
legal_type = gr.Dropdown(choices=["OEM", "Supplier", "Distributor"], label="Legal Entity Type", value="OEM")
# Location Section
gr.HTML("<div class='section-title'>πŸ“ Business Location</div>")
with gr.Row(elem_classes="input-group"):
with gr.Column():
country = gr.Dropdown(choices=["India"], value="India", label="Country")
state = gr.Dropdown(choices=["Haryana", "Karnataka"], value="Haryana", label="State")
city = gr.Dropdown(choices=["Faridabad", "Bangalore"], value="Faridabad", label="City")
with gr.Column():
plant_address = gr.Textbox(label="Plant Address", placeholder="Enter your complete plant address...", lines=2)
postal_code = gr.Textbox(label="Postal Code", value="121002")
# Legal Identifiers Section
gr.HTML("<div class='section-title'>πŸ“‹ Legal Identifiers</div>")
with gr.Row(elem_classes="input-group"):
with gr.Column():
with gr.Row():
gstin = gr.Textbox(label="GSTIN", value="22AAAAA0000A1Z5")
gr.HTML("<span class='verification-badge badge-verified'>βœ“ Verified</span>")
with gr.Row():
pan = gr.Textbox(label="PAN", value="AAAAA0000A")
gr.HTML("<span class='verification-badge badge-verified'>βœ“ Verified</span>")
with gr.Row():
cin = gr.Textbox(label="CIN", value="L01631KA2010PTC096843")
gr.HTML("<span class='verification-badge badge-verified'>βœ“ Verified</span>")
with gr.Column():
global_id_type = gr.Dropdown(choices=["DUNS", "LEI"], value="DUNS", label="Global ID Type")
global_id = gr.Textbox(label="Global ID Number", value="XXYYZZ1234567890")
# Status Section
gr.HTML("""
<div class='status-section'>
<div class='status-badges'>
<span class='verification-badge badge-verified'>βœ… Auto-Verified (Government Database)</span>
<span class='verification-badge badge-pending'>⏳ Approval Pending</span>
</div>
<div class='access-level'>
<strong>Access Level:</strong> Public & Private Infrastructure
</div>
</div>
""")
# Registration Summary
gr.HTML("<div class='section-title'>πŸ“Š Registration Summary</div>")
gr.HTML("""
<table class='summary-table'>
<tr>
<td>Registration Date</td>
<td>29/05/2025 11:02:02 AM</td>
</tr>
<tr>
<td>Last Updated</td>
<td>29/05/2025 12:07:23 PM</td>
</tr>
<tr>
<td>Updated By</td>
<td>SYSTEM-ADMIN</td>
</tr>
<tr>
<td>Approval Date</td>
<td>29/05/2025 12:07:23 PM</td>
</tr>
<tr>
<td>Approved By</td>
<td>ADMIN-APPROVER</td>
</tr>
</table>
""")
# Output for success message
output = gr.HTML()
# Submit Button
submit_btn = gr.Button("πŸš€ Submit Registration", elem_classes="submit-btn")
submit_btn.click(
submit_action,
[legal_name, legal_type, country, state, city, plant_address, postal_code,
gstin, pan, cin, global_id_type, global_id],
output
)
demo.launch()