web命令用户界面
webcui的Python项目详细描述
网络用户界面
用于创建WebUI应用程序的Python包。WebUI应用程序对于Web就像命令行界面应用程序对于命令行一样。 webgui的目标是让python开发人员尽可能容易地与世界共享他们的python应用程序。
网络用户界面理念:
- 带有html表单的web页面是从基本的python函数生成的。
- 函数参数成为输入字段。
- 该函数在用户提交表单时执行。
- 结果显示在网页上。
安装
安装Python3.6或更高版本,然后使用PIP安装WebUI。
$ pip install webcui
用法
下面是一个简单的WebUI应用程序的示例:
importwebcuidefcmd(number_of_spam:int,side:str="eggs"):"""Calculate the price of a breakfast order."""spams=number_of_spam*["spam"]dish=f"{', '.join(spams)} and {side}"price=number_of_spam*1.5+2returnf"The price of an order of {dish} is €{price:.2f}"if__name__=='__main__':webcui.run(cmd)
要在自己的计算机上运行WebUI应用程序,请运行:
$ python app.py --run