mirror of
https://github.com/gradio-app/gradio.git
synced 2025-01-12 10:34:32 +08:00
fixed flagging
This commit is contained in:
parent
cb444fa4d4
commit
8d6ab2eec0
@ -32,7 +32,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 3,
|
||||
"execution_count": 5,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
@ -47,9 +47,9 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 4,
|
||||
"execution_count": 6,
|
||||
"metadata": {
|
||||
"scrolled": false
|
||||
"scrolled": true
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
@ -57,8 +57,8 @@
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"NOTE: Gradio is in beta stage, please report all bugs to: contact.gradio@gmail.com\n",
|
||||
"Model is running locally at: http://localhost:7861/\n",
|
||||
"Model available publicly at: https://30008.gradio.app -- may take up to a minute to setup.\n"
|
||||
"Model is running locally at: http://localhost:7862/\n",
|
||||
"To create a public link, set `share=True` in the argument to `launch()`.\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
@ -68,14 +68,14 @@
|
||||
" <iframe\n",
|
||||
" width=\"1000\"\n",
|
||||
" height=\"500\"\n",
|
||||
" src=\"http://localhost:7861/\"\n",
|
||||
" src=\"http://localhost:7862/\"\n",
|
||||
" frameborder=\"0\"\n",
|
||||
" allowfullscreen\n",
|
||||
" ></iframe>\n",
|
||||
" "
|
||||
],
|
||||
"text/plain": [
|
||||
"<IPython.lib.display.IFrame at 0x1cc809aa940>"
|
||||
"<IPython.lib.display.IFrame at 0x1f6784e2f60>"
|
||||
]
|
||||
},
|
||||
"metadata": {},
|
||||
@ -83,7 +83,7 @@
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"io.launch(inline=True, inbrowser=True, share=True, validate=False);"
|
||||
"io.launch(inline=True, inbrowser=False, share=False, validate=False);"
|
||||
]
|
||||
}
|
||||
],
|
||||
|
@ -37,6 +37,9 @@ CONFIG_FILE = "static/config.json"
|
||||
ASSOCIATION_PATH_IN_STATIC = "static/apple-app-site-association"
|
||||
ASSOCIATION_PATH_IN_ROOT = "apple-app-site-association"
|
||||
|
||||
FLAGGING_DIRECTORY = 'gradio-flagged/{}'
|
||||
FLAGGING_FILENAME = 'gradio-flagged.txt'
|
||||
|
||||
|
||||
def build_template(temp_dir, input_interface, output_interface):
|
||||
"""
|
||||
@ -219,13 +222,12 @@ def serve_files_in_background(interface, port, directory_to_serve=None):
|
||||
|
||||
elif self.path == "/api/flag/":
|
||||
msg = json.loads(data_string)
|
||||
dir = f'gradio-flagged/{interface.hash}'
|
||||
os.makedirs((dir), exist_ok=True)
|
||||
with open(f'{dir}/gradio-flagged.txt','a+') as f:
|
||||
message = ''
|
||||
if 'message' in msg:
|
||||
message = msg['data']['message']
|
||||
dict = {'input': interface.input_interface.rebuild_flagged(dir,msg), 'output': interface.output_interface.rebuild_flagged(dir,msg), 'message': message}
|
||||
flag_dir = FLAGGING_DIRECTORY.format(interface.hash)
|
||||
os.makedirs(flag_dir, exist_ok=True)
|
||||
dict = {'input': interface.input_interface.rebuild_flagged(flag_dir, msg),
|
||||
'output': interface.output_interface.rebuild_flagged(flag_dir, msg),
|
||||
'message': msg['data']['message']}
|
||||
with open(os.path.join(flag_dir, FLAGGING_FILENAME), 'a+') as f:
|
||||
f.write(json.dumps(dict))
|
||||
f.write("\n")
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user