mirror of
https://github.com/gradio-app/gradio.git
synced 2025-04-06 12:30:29 +08:00
added ability to build interface from command line
This commit is contained in:
parent
b2817ec4b0
commit
1b9f292718
16
build-interface.py
Normal file
16
build-interface.py
Normal file
@ -0,0 +1,16 @@
|
||||
from argparse import ArgumentParser
|
||||
import gradio
|
||||
|
||||
parser = ArgumentParser(description='Arguments for Building Interface')
|
||||
parser.add_argument('-i', '--inputs', type=str, help="name of input interface")
|
||||
parser.add_argument('-o', '--outputs', type=str, help="name of output interface")
|
||||
args = parser.parse_args()
|
||||
|
||||
|
||||
def launch_interface(args):
|
||||
io = gradio.Interface(inputs=args.inputs, outputs=args.outputs, model=lambda x:x, model_type='function')
|
||||
io.launch()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
launch_interface(args)
|
@ -142,6 +142,7 @@ class Interface:
|
||||
else:
|
||||
if self.verbose:
|
||||
print("To create a public link, set `share=True` in the argument to `launch()`")
|
||||
site_ngrok_url = None
|
||||
|
||||
# Keep the server running in the background.
|
||||
asyncio.get_event_loop().run_until_complete(start_server)
|
||||
@ -151,3 +152,4 @@ class Interface:
|
||||
pass
|
||||
|
||||
webbrowser.open(path_to_server + networking.TEMPLATE_TEMP) # Open a browser tab with the interface.
|
||||
return path_to_server + networking.TEMPLATE_TEMP, site_ngrok_url
|
Loading…
x
Reference in New Issue
Block a user