Naisong Zhou commited on
Commit
b4d2108
·
1 Parent(s): 947ca60

disable copy paste

Browse files
Files changed (2) hide show
  1. app.py +7 -11
  2. html_codes.py +25 -0
app.py CHANGED
@@ -4,7 +4,7 @@ from save_data import add_new_data, get_sheet_service
4
  from instructions import *
5
  from user_groups import user_data
6
  from constants import SDG_DETAILS, GPT_PROMPT_parallel, GPT_PROMPT_sequential, GPT_PROMPT_reverse_sequential
7
-
8
 
9
  class SessionManager:
10
  def __init__(self):
@@ -146,21 +146,17 @@ def update_word_count(text):
146
  return f"Word Count: {len(words)}"
147
 
148
  if __name__ == "__main__":
149
- api_key = get_api_key(local=False)
150
- service, SHEET_IDs = get_sheet_service(local=False)
 
151
  SHEET_ID1, SHEET_ID2, SHEET_ID3 = SHEET_IDs
152
 
153
  session_manager = SessionManager()
154
 
155
  with gr.Blocks(fill_width=True,
156
- css = """
157
- .gradio-container {
158
- background: url('https://platform.vox.com/wp-content/uploads/sites/2/chorus/uploads/chorus_asset/file/9376591/blade3.jpg');
159
- background-size: cover;
160
- background-attachment: fixed;
161
- background-position: center;
162
- }
163
- """) as app:
164
  title = gr.HTML("<h1 style='color: white;'> Human-AI Ensemble </h1>")
165
  with gr.Row():
166
  identification_code = gr.Textbox(label="Enter your identification code")
 
4
  from instructions import *
5
  from user_groups import user_data
6
  from constants import SDG_DETAILS, GPT_PROMPT_parallel, GPT_PROMPT_sequential, GPT_PROMPT_reverse_sequential
7
+ from html_codes import *
8
 
9
  class SessionManager:
10
  def __init__(self):
 
146
  return f"Word Count: {len(words)}"
147
 
148
  if __name__ == "__main__":
149
+ deploy_local = False
150
+ api_key = get_api_key(local=deploy_local)
151
+ service, SHEET_IDs = get_sheet_service(local=deploy_local)
152
  SHEET_ID1, SHEET_ID2, SHEET_ID3 = SHEET_IDs
153
 
154
  session_manager = SessionManager()
155
 
156
  with gr.Blocks(fill_width=True,
157
+ css = background_css,
158
+ js = no_copy_paste_js
159
+ ) as app:
 
 
 
 
 
160
  title = gr.HTML("<h1 style='color: white;'> Human-AI Ensemble </h1>")
161
  with gr.Row():
162
  identification_code = gr.Textbox(label="Enter your identification code")
html_codes.py ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ no_copy_paste_js = """
2
+ function disableCopyPaste() {
3
+ // 禁用复制
4
+ document.addEventListener('copy', (event) => {
5
+ event.preventDefault();
6
+ alert('Copy has been disabled.');
7
+ });
8
+
9
+ // no paste
10
+ document.addEventListener('paste', (event) => {
11
+ event.preventDefault();
12
+ alert('Paste has been disabled, please type your original answer.');
13
+ });
14
+
15
+ }
16
+ """
17
+
18
+ background_css = """
19
+ .gradio-container {
20
+ background: url('https://platform.vox.com/wp-content/uploads/sites/2/chorus/uploads/chorus_asset/file/9376591/blade3.jpg');
21
+ background-size: cover;
22
+ background-attachment: fixed;
23
+ background-position: center;
24
+ }
25
+ """