File size: 645 Bytes
382017b faf3f39 ad71468 382017b 8cfcc01 382017b faf3f39 b324a8a |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
import gradio as gr
from yanghao.portlink import PortLinkClient as Client
import asyncio
# 全局端口配置
PORT = 7860
def greet(name):
return "Hello " + name + "!"
demo = gr.Interface(fn=greet, inputs="text", outputs="text")
async def launchGradio():
demo.launch(server_name="0.0.0.0", server_port=PORT)
async def main():
gr_task = asyncio.create_task(launchGradio())
# Expose port to the public internet. Check the debug output for the specific public URL.
async with Client(PORT) as c:
await c.link(PORT)
if __name__ == "__main__":
import nest_asyncio
nest_asyncio.apply()
asyncio.run(main())
|