Python 烧瓶及;API:尝试从flask发送请求
我现在正在构建一个登录系统,我需要从HTML发送请求。为此,我使用以下脚本:Python 烧瓶及;API:尝试从flask发送请求,python,html,flask,Python,Html,Flask,我现在正在构建一个登录系统,我需要从HTML发送请求。为此,我使用以下脚本: <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Login Form</title> <link rel="stylesheet" href="static/style.css"> </head> <bo
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Login Form</title>
<link rel="stylesheet" href="static/style.css">
</head>
<body>
<div class="login-box">
<h1>INTERKODAS.LT</h1>
<div class="textbox">
<i class="fa fa-user" aria-hidden="true"></i>
<input type="email" placeholder="Email Address" name="email" value="">
</div>
<form action="http://127.0.0.1:8080/api/test?" method="POST" target="_blank">
<div class="textbox">
<i class="fa fa-lock" aria-hidden="true"></i>
<input type="password" placeholder="category" name="category" value="">
</div>
<input class="btn" type="submit" name="" value="Sign in">
</form>
</div>
<div class="copyright">
<h4>©™ 2019 Copyright All Rights Reserved</h4>
</div>
</body>
</html>
登录表单
INTERKODAS.LT
©™ 2019版权所有
问题是它发送请求,但不插入任何值。例如,当我使用GET方法时,它会在请求中插入一个值。如何在该链接中插入值?
正确的post方法是-
后端代码(Python):
##======================请求
异步def句柄(请求):
get_time=datetime.datetime.now().strftime(“%b%y%H.%M:%S”)
object_name='Lempa'#request.query['name']
类别=请求。查询['category']
打印('类别搜索',类别)
如果类别或len(类别)中的“”显示后端代码。@NarasimhaPrasannaHN
##================== Requests
async def Handle(request):
get_time = datetime.datetime.now().strftime("%b %y %H.%M:%S")
object_name = 'Lempa'#request.query['name']
category = request.query['category']
print('Category search',category)
if ' ' in category or len(category) <=2: #Short-Name
response_obj = {"status" : "error", "message" : "short name","name" : f"{object_name}", "search_time" : f"{get_time}", "category" : f"{category}"}
return web.Response(text=json.dumps(response_obj), status = 401)
else:# Success
# self.item_id, self.item_category, self.item_name, self.item_desc,self.item_ins, self.item_price, self.item_upload_date
#Scan_Item = LoadItems()
#itemid, item_category, item_name, item_desc, item_ins, item_price, item_upload = Scan_Item.search_by_category(category)
Loadinam = LoadItems()
Loadinam.search_by_category()
response_obj = {"status" : "ok", "message" : "success","name" : f"{category}", "search_time" : f"{get_time}", "category" : f"{category}", "in_stock" : f"{category}", "price" : f"{category}"}
content={
"server": "running",
"locale": "en",
"status": "ok",
"search_time" : f"{get_time}",
"name": f"{category}",
"category" : f"{category}",
"in_stock" : f"{category}",
"item_id" : f"{category}",
"price" : f"{category}",
"item_desc" : f"{category}",
"item_upload" : f"{category}"
}
return web.Response(text=json.dumps(content), status = 200)