コード例 #1
0
def get_last_requests():
    requests = []
    file_requests = open('last_requests', 'r')
    for request in file_requests.readlines():
        if len(request) > 1:
            requests.append(request.strip())
    file_requests.close()
    return requests
コード例 #2
0
def getDataFromBase(category, identifier, request):
    debugHelp(message='GETDATAFROMBASE')
    this_request = {
        'category': category,
        'identifier': identifier,
        'request': request
    }
    print("you are requesting::", this_request)
    query = "SELECT {} FROM users WHERE {}='{}';".format(
        category.strip("'"), identifier.strip("'"), request.strip("'"))
    print("you are querying::", query)
    result = mysql.query_db(query)
    if not (result):
        print('no such data')
        return False
    else:
        print("you get::", result)
        return result
コード例 #3
0
ファイル: response.py プロジェクト: jiazifa/site-hub-server
def __check_request(method: str = "") -> str:
    """
    检查返回的错误信息是否合规则
    :param request: 返回的请求地址
    :return: 如果请求的地址为空,则返回空字符串
    """
    methods: List[str] = ["get", "post", "put", "patch", "delete", "*"]
    request: str = method.lower()
    request = request.strip()
    if len(request) == 0:
        return ""

    for method in methods:
        if request.startswith(method):
            request = request.replace(method, method.upper())
            break
    else:
        request = "GET {}".format(request)
    return request
コード例 #4
0
ファイル: common.py プロジェクト: tom2jack/Market_B
def __checkRequest(request="") -> str:
    """
    检查返回的错误信息是否合规则
    :param request: 返回的请求地址
    :return: 如果请求的地址为空,则返回空字符串
    """
    methods = ['get', 'post', 'put', 'patch', 'delete', '*']
    request = request.lower()
    request = request.strip()
    if len(request) == 0:
        return ""

    for method in methods:
        if request.startswith(method):
            request = request.replace(method, method.upper())
            break
    else:
        request = "GET {}".format(request)
    return request
コード例 #5
0
ファイル: server.py プロジェクト: eliottalderson93/the_wall
def getDataFromBase(category,table,identifier,request):
    #debugHelp(message ='GETDATAFROMBASE')
    this_request = {'category':category,'table':table,identifier:'identifier',request:'request'}
    #print("you are requesting::",this_request)
    query = "SELECT {} FROM {} WHERE {}='{}';".format(category.strip("'"),table.strip("'"),identifier.strip("'"),request.strip("'"))
    #print("you are querying::",query)
    result = mysql.query_db(query)
    if not(result):
        print('no such data')
        return False
    else:
        #print("you get::", result[0]['{}'.format(category.strip("'"))])
        final = result[0]['{}'.format(category.strip("'"))]
        return final