一个非常轻量级和简单的api服务器,构建在socketserver模块上

meager的Python项目详细描述


微薄

meager是一个基于python中的socketserver模块构建的小型web框架。

Codacy BadgeBuild StatusPython Versions

安装

PyPI上可以买到微薄的。

您可以使用pip安装meager:pip install meager

示例

这是使用meager的最简单方法,在请求返回到“/”时返回html。

该模块深受烧瓶的启发,使用方便,可读性强。

返回html

的示例
importmeagerapp=meager.Server(host="0.0.0.0",port=8080)# Set binding ip address and port, default is localhost:2090@app.router.route("/")defindex(request):return"<h1>Hello world!</h1>"app.serve()

返回json

的示例
importmeagerapp=meager.Server()example_dict={"key1":"val1","key2":"val2"}@app.router.route("/")defindex(request):returnexample_dict# It can detect if you're sending a dictionary# and automatically changes the "Content-Type:" header to application/json app.serve()

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
二进制字符串的java NumberFormatExceprion   java如何在Neo4j中查找/匹配/选择标识符名称   java哪一年的日期与原始年份相同?   java什么时候JAXB可以用于Json而不是XML?   java使用PayPal权限API进行PayPal支付   java Getting error在使用安卓 vision api扫描二维码时加载图像失败   java直接突出显示RichTextFX中的一个文本范围   java Resolve@RegisteredAuth2AuthorizedClient,其令牌在spring Security 5.2的spring server之外获得。十、   yyyymmddhhmmss的Java正则表达式   java我试图将google recaptcha与spring mvc集成,但GreCaptCharResponse总是返回false。这里有一些代码   java使用JsonPath将文本转换为json   java无法解析符号。Maven依赖项已就位,但代码为红色   java使用循环查找范围内具有不同数字的数字   java这个SwingWorker是否不重用ThreadPoolExecutor中的线程?