def user_info(username): if username not in users: raise Exception('Not found') result = users[username] return nice_json(result)
def hello(): return nice_json({ "uri": "/", "sub_uri": { "companies": "/companies", "company": "/company/<id>", } })
def user_jobs(username): if username not in jobs: raise Exception('Not found') result = jobs[username] return nice_json(result)
def company_info(id): if id not in companies: raise Exception('Not found') result = companies[id] result["uri"] = request.url return nice_json(result)
def hello(): return nice_json( { "uri": "/", "sub_uri":{ "jobs": "/jobs", "user_jobs": "/jobs/<username>", } } )
def hello(): return nice_json( { "uri": "/", "sub_uri":{ "users": "/users", "user": "******", "jobs": "/user/<username>/jobs", "suggested": "/user/<username>/suggestions", } } )
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)
def companies_info(): return nice_json(users)
def companies_info(): return nice_json(companies)
def jobs_info(): return nice_json(jobs)