首页 新闻 会员 周边 捐助

tornado-RequestHandler 中get参数api值一直是空?

0
[待解决问题]
tornado-MainHandler(RequestHandler) 中get参数api值一直是空
 
源码:
import json
import tornado.ioloop
import tornado.web
from tornado.web import RequestHandler , Application
 
class MainHandler(RequestHandler):
def get(self , api=""):
"""
 
根据用户请求的api,返回对应的数据
:param api : 用户请求的应用接口
"""
print("api is " , api)
if not api:
links = ["random" , "names" , "proxies" , "all" , "count"]
self.write("<h4>welcome to adsl api!</h4>")
for link in links:
self.write("<a href={link}> {link}</a><br/>".format(link=link))
 
def server(port=8000 , address=""):
"""
 
创建启动web服务器框架
"""
app = Application([
(r"/" , MainHandler) ,
(r"/.*" , MainHandler)
])
app.listen(port=port , address=address)
print("adsl api listen on " , port)
tornado.ioloop.IOLoop.instance().start()
 
if __name__ == "__main__":
server()
 

两袖清风的主页 两袖清风 | 菜鸟二级 | 园豆:202
提问于:2020-04-14 19:17
< >
分享
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册