Upload folder using huggingface_hub
Browse files
.DS_Store
ADDED
Binary file (6.15 kB). View file
|
|
test.py
CHANGED
@@ -1,10 +1,12 @@
|
|
1 |
import gradio as gr
|
2 |
|
3 |
-
def
|
4 |
-
|
|
|
|
|
5 |
|
6 |
-
|
7 |
-
.
|
8 |
display: none;
|
9 |
position: fixed;
|
10 |
z-index: 1000;
|
@@ -14,18 +16,20 @@ def create_policy_modal_app():
|
|
14 |
height: 100%;
|
15 |
background-color: rgba(0,0,0,0.7);
|
16 |
overflow: auto;
|
17 |
-
justify-content: center;
|
18 |
-
align-items: center;
|
19 |
}
|
20 |
-
|
|
|
21 |
background-color: white;
|
22 |
margin: 2% auto;
|
23 |
padding: 20px;
|
24 |
width: 90%;
|
25 |
max-width: 900px;
|
|
|
|
|
26 |
border-radius: 8px;
|
27 |
position: relative;
|
28 |
}
|
|
|
29 |
.close-btn {
|
30 |
position: absolute;
|
31 |
right: 15px;
|
@@ -37,51 +41,56 @@ def create_policy_modal_app():
|
|
37 |
border: none;
|
38 |
border-radius: 4px;
|
39 |
padding: 5px 15px;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
40 |
}
|
41 |
-
"""
|
42 |
|
43 |
-
|
44 |
-
|
45 |
-
|
|
|
|
|
|
|
46 |
|
47 |
modal_html = f"""
|
48 |
-
<div id="
|
49 |
-
<div class="
|
50 |
-
<button class="close-btn" onclick="document.getElementById('
|
51 |
-
|
|
|
|
|
52 |
</div>
|
53 |
</div>
|
54 |
"""
|
55 |
|
56 |
-
with gr.Blocks(css=
|
|
|
57 |
gr.HTML(modal_html)
|
58 |
-
button = gr.Button("View Hate Speech Policy")
|
59 |
|
60 |
-
|
61 |
-
function() {
|
62 |
-
const modal = document.getElementById('policyModal');
|
63 |
-
if (modal) {
|
64 |
-
modal.style.display = 'flex';
|
65 |
-
document.body.style.overflow = 'hidden';
|
66 |
-
}
|
67 |
-
return [];
|
68 |
-
}
|
69 |
-
""")
|
70 |
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
|
|
|
|
|
|
82 |
|
83 |
return app
|
84 |
|
85 |
if __name__ == "__main__":
|
86 |
-
app =
|
87 |
app.launch()
|
|
|
1 |
import gradio as gr
|
2 |
|
3 |
+
def create_policy_popup_app():
|
4 |
+
# Your Google Drive file ID
|
5 |
+
pdf_id = "1WZCQpIWfelbxgBr8dNiW2rqVGaDyf-Gi"
|
6 |
+
embed_url = f"https://drive.google.com/file/d/{pdf_id}/preview"
|
7 |
|
8 |
+
custom_css = """
|
9 |
+
.pdf-modal {
|
10 |
display: none;
|
11 |
position: fixed;
|
12 |
z-index: 1000;
|
|
|
16 |
height: 100%;
|
17 |
background-color: rgba(0,0,0,0.7);
|
18 |
overflow: auto;
|
|
|
|
|
19 |
}
|
20 |
+
|
21 |
+
.pdf-modal-content {
|
22 |
background-color: white;
|
23 |
margin: 2% auto;
|
24 |
padding: 20px;
|
25 |
width: 90%;
|
26 |
max-width: 900px;
|
27 |
+
height: 90%;
|
28 |
+
box-shadow: 0 5px 15px rgba(0,0,0,0.3);
|
29 |
border-radius: 8px;
|
30 |
position: relative;
|
31 |
}
|
32 |
+
|
33 |
.close-btn {
|
34 |
position: absolute;
|
35 |
right: 15px;
|
|
|
41 |
border: none;
|
42 |
border-radius: 4px;
|
43 |
padding: 5px 15px;
|
44 |
+
z-index: 1001;
|
45 |
+
}
|
46 |
+
|
47 |
+
.pdf-container {
|
48 |
+
width: 100%;
|
49 |
+
height: calc(100% - 40px);
|
50 |
+
margin-top: 40px;
|
51 |
}
|
|
|
52 |
|
53 |
+
.pdf-embed {
|
54 |
+
width: 100%;
|
55 |
+
height: 100%;
|
56 |
+
border: 1px solid #ddd;
|
57 |
+
}
|
58 |
+
"""
|
59 |
|
60 |
modal_html = f"""
|
61 |
+
<div id="pdfModal" class="pdf-modal">
|
62 |
+
<div class="pdf-modal-content">
|
63 |
+
<button class="close-btn" onclick="document.getElementById('pdfModal').style.display='none';document.body.style.overflow='auto';">×</button>
|
64 |
+
<div class="pdf-container">
|
65 |
+
<iframe class="pdf-embed" src="{embed_url}" type="application/pdf"></iframe>
|
66 |
+
</div>
|
67 |
</div>
|
68 |
</div>
|
69 |
"""
|
70 |
|
71 |
+
with gr.Blocks(css=custom_css) as app:
|
72 |
+
gr.Markdown("## View Hate Speech Policy")
|
73 |
gr.HTML(modal_html)
|
|
|
74 |
|
75 |
+
open_button = gr.Button("📄 Open Policy Document")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
76 |
|
77 |
+
open_button.click(
|
78 |
+
fn=lambda: None,
|
79 |
+
inputs=None,
|
80 |
+
outputs=None,
|
81 |
+
js="""
|
82 |
+
() => {
|
83 |
+
const modal = document.getElementById('pdfModal');
|
84 |
+
if (modal) {
|
85 |
+
modal.style.display = 'block';
|
86 |
+
document.body.style.overflow = 'hidden';
|
87 |
+
}
|
88 |
+
}
|
89 |
+
"""
|
90 |
+
)
|
91 |
|
92 |
return app
|
93 |
|
94 |
if __name__ == "__main__":
|
95 |
+
app = create_policy_popup_app()
|
96 |
app.launch()
|