fastapi
import fastapi
from fastapi import Form
from starlette.requests import Request
import uvicorn
import tools
server = fastapi.FastAPI()
@server.get('/login')
def login(username: str, password: str):
if username.strip() and password.strip():
p = tools.my_md5(password)
query_sql = 'select * from app_myuser where username= "%s" and passwd=%s;' % (username, p)
if tools.excute(query_sql):
return {
'code': '0', 'msg': '登录成功'}
else:
return {
'code': '-1', 'msg': '输入的用户名/密码错误'}
else:
return {
'code': '-1', 'msg': '不能为空'}
@server.get('/product')
def test():
return {
'code':0,
'data':[
{
'product_name':'朝朝盈1号','status'