m7n commited on
Commit
1fef6b4
·
verified ·
1 Parent(s): 509d4f0

Update main.py

Browse files
Files changed (1) hide show
  1. main.py +16 -0
main.py CHANGED
@@ -29,6 +29,22 @@ app.mount("/static", StaticFiles(directory="static"), name="static")
29
  # Tell Gradio which paths are allowed to be served
30
  os.environ["GRADIO_ALLOWED_PATHS"] = str(static_dir.resolve())
31
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
32
  @spaces.GPU(duration=4*60) # Specify GPU duration in seconds, added for testing
33
  def process_text(text):
34
  """Example GPU function - in reality, this might be model inference"""
 
29
  # Tell Gradio which paths are allowed to be served
30
  os.environ["GRADIO_ALLOWED_PATHS"] = str(static_dir.resolve())
31
 
32
+
33
+ token = _get_token(gr.Request)
34
+ payload = token.split('.')[1]
35
+ payload = f"{payload}{'=' * ((4 - len(payload) % 4) % 4)}"
36
+ payload = json.loads(base64.urlsafe_b64decode(payload).decode())
37
+ print(f"Token payload outside of function: {payload}") # For debugging
38
+
39
+
40
+ @spaces.GPU(1) # Specify GPU duration in seconds, added for testing
41
+ def init_gpu(text):
42
+ """Example GPU function - in reality, this might be model inference"""
43
+ time.sleep(10)
44
+
45
+ init_gpu()
46
+
47
+
48
  @spaces.GPU(duration=4*60) # Specify GPU duration in seconds, added for testing
49
  def process_text(text):
50
  """Example GPU function - in reality, this might be model inference"""