yuji96 commited on
Commit
b713115
·
verified ·
1 Parent(s): c8ea449

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +39 -0
app.py ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import os
3
+ from random import random
4
+
5
+
6
+ flag = os.getenv("FLAG")
7
+
8
+
9
+ def main(request: str) -> str:
10
+ you = float(input())
11
+
12
+ N = 10000
13
+ enemys = [random() * 2 * you for _ in range(N)]
14
+
15
+ win_count = 0
16
+ for r in enemys:
17
+ if not (you <= r):
18
+ win_count += 1
19
+
20
+ if win_count == N:
21
+ return f"勝利! pgctf{flag}"
22
+ else:
23
+ return f"あなたは {win_count} 人に勝ちました。"
24
+
25
+
26
+
27
+ demo = gr.Interface(
28
+ fn=main,
29
+ inputs=[
30
+ gr.Textbox(label="request"),
31
+ ],
32
+ outputs=[
33
+ gr.Textbox(label="response"),
34
+ ],
35
+ )
36
+
37
+ demo.launch()
38
+
39
+