-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy path__init__.py
81 lines (62 loc) · 1.79 KB
/
__init__.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
from flask import Flask, redirect
import random
app = Flask(__name__)
"""
TASK
Implement an endpoint `/api/fetch` that returns the contents of `data.csv` as JSON
1) Load/transcribe `data.csv`
2) Save each entry's full name, time zone, and department
3) Return the JSON data at the endpoint
"""
# your work here
"""
DOCUMENTATION WEBPAGE BELOW
"""
@app.route("/")
def redirect_to_api():
return redirect("/api", code=301)
@app.route("/api")
def api_home():
return """
<style>
body {
font-family: sans-serif;
max-width: 900px;
width: 90%;
margin: 0 auto 0 auto;
padding: 5vh 30px 0 30px;
background: rgb(240,240,240);
}
pre, code {
background: #121212;
color: white;
}
code {
padding: 4px;
}
pre code {
padding: 0;
}
pre {
padding: 10px;
}
hr {
margin: 2em 0;
}
</style>
<h1>Founders Fall 2020 Backend Take-Home API</h1>
<p>Add the endpoint <code>`/api/fetch`</code> accessible via a GET request which returns the list of employees from <code>`data.csv`</code> as JSON.</p><hr />
<h2>API (to be implemented)</h2>
<h4>Request</h4>
<pre><code><b>GET</b>
Scheme: http
Filename: /api/fetch</code></pre>
<h4>Response</h4>
<pre><code>employees: [
<br /> {
<br /> name: <i>FULL NAME OF EMPLOYEE</i>,
<br /> timezone: <i>TIMEZONE</i>,
<br /> dept: <i>EMPLOYEE'S DEPARTMENT</i>,
<br /> }
<br /> ...
<br />]</code></pre>"""