コード例 #1
0
def user_info(username):

    if username not in users:
        raise Exception('Not found')

    result = users[username]

    return nice_json(result)
コード例 #2
0
def hello():
    return nice_json({
        "uri": "/",
        "sub_uri": {
            "companies": "/companies",
            "company": "/company/<id>",
        }
    })
コード例 #3
0
def user_jobs(username):

    if username not in jobs:
        raise Exception('Not found')

    result = jobs[username]

    return nice_json(result)
コード例 #4
0
def company_info(id):

    if id not in companies:
        raise Exception('Not found')

    result = companies[id]
    result["uri"] = request.url

    return nice_json(result)
コード例 #5
0
def hello():
    return nice_json(
        {
            "uri": "/",
            "sub_uri":{
                        "jobs": "/jobs",
                        "user_jobs": "/jobs/<username>",
                        }
        }
    )
コード例 #6
0
def hello():
    return nice_json(
        {
            "uri": "/",
            "sub_uri":{
                        "users": "/users",
                        "user": "******",
                        "jobs": "/user/<username>/jobs",
                        "suggested": "/user/<username>/suggestions",
                        }
        }
    )
コード例 #7
0
def user_jobs(username):

    if username not in users:
        raise Exception('User not found')

    try:
        user_jobs= requests.get("http://127.0.0.1:5003/jobs/{}".format(username))
    except Exception as e: #check connection
        raise Exception("Job service is not unavailable")

    if user_jobs.status_code ==404:
        raise Exception("No jobs found")

    user_jobs = user_jobs.json()

    result = {}

    for date, jobs in user_jobs.items():
        result[date]=[]
        for company_id in jobs:

            try:
                company = requests.get("http://127.0.0.1:5001/company/{}".format(company_id))
            except Exception as e:
                raise Exception("Company service is not unavailable")


            if company.status_code == 404:
                raise Exception("No company found")

            company = company.json()

            result[date].append({
                "title":company["title"],
                "rating": company["rating"],
                "uri": company["uri"],
            })


    return nice_json(result)
コード例 #8
0
def companies_info():
    return nice_json(users)
コード例 #9
0
def companies_info():
    return nice_json(companies)
コード例 #10
0
def jobs_info():
    return nice_json(jobs)