Skip to content

Commit 6a4314b

Browse files
committed
v2 complete
1 parent 83a2c5c commit 6a4314b

File tree

3 files changed

+15
-14
lines changed

3 files changed

+15
-14
lines changed

src/api.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
""" Data Retrieval and Serialization """
22
import logging
3-
import os
43

54
import psycopg2
65
from fastapi import FastAPI
76
from fastapi.middleware.cors import CORSMiddleware
87
from fastapi.staticfiles import StaticFiles
98

10-
from src.caching import get_user_from_redis
9+
from src.storage import get_user_from_redis
1110

1211
logging.basicConfig(
1312
level=logging.INFO,
@@ -27,15 +26,15 @@
2726

2827

2928
# Mount the Frontend
30-
app.mount("/static", StaticFiles(directory="/app/static"), name="static")
29+
app.mount("/static", StaticFiles(directory="/app/static/dist/"), name="static")
3130

3231

3332
@app.get("/")
3433
async def root():
3534
return {"message": "I am Root"}
3635

3736

38-
@app.get("/api/datapipe/list-users")
37+
@app.get("/api/v2/datapipeline/list-users")
3938
async def list_users():
4039
"""
4140
Retrieve a list of users from the database.
@@ -61,7 +60,7 @@ async def list_users():
6160
return {"message": str(e)}
6261

6362

64-
@app.get("/api/datapipe/{user_id}")
63+
@app.get("/api/v2/datapipeline/{user_id}")
6564
async def get_user(user_id: str):
6665
"""
6766
Retrieve user information from the database.

src/storage.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,14 @@
88
Typical usage example:
99
1010
user_data = {}
11-
users_addresss_data = {}
11+
users_address_data = {}
1212
1313
if check_table_exists("users") and check_table_exists("users_address"):
1414
for user in user_data:
1515
if insert_into_user_table(user):
1616
logging.info(green(f"User: {user['uid']} added successfully"))
1717
18-
for address in users_addresss_data:
18+
for address in users_address_data:
1919
if insert_into_address_table(address):
2020
logging.info(
2121
green(f"Address for User: {address['uid']} added successfully")
@@ -31,7 +31,7 @@
3131
if insert_into_user_table(user):
3232
logging.info(green(f"User: {user['uid']} added successfully"))
3333
34-
for address in users_addresss_data:
34+
for address in users_address_data:
3535
if insert_into_address_table(address):
3636
logging.info(
3737
green(f"Address for User: {address['uid']} added successfully")

static/src/App.jsx

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,15 @@ function App() {
77
const [user, setUser] = useState([])
88

99
const getUser = async userID => {
10-
await fetch(`http://127.0.0.1:80/api/datapipe/${userID}`)
10+
await fetch(`http://127.0.0.1:80/api/v2/datapipeline/${userID}`)
1111
.then(response => response.json())
1212
.then(data => setUser(data))
1313
.catch(error => console.error(error))
1414
}
1515

1616
useEffect(() => {
1717
// generate a list of users on mount
18-
fetch(`http://127.0.0.1:80/api/datapipe/list-users`)
18+
fetch(`http://127.0.0.1:80/api/v2/datapipeline/list-users`)
1919
.then(response => response.json())
2020
.then(data => {
2121
setUsers(data)
@@ -62,7 +62,7 @@ function App() {
6262
}
6363

6464
return (
65-
<div className="container mx-auto max-w-[960px] overflow-auto">
65+
<div className="container mx-auto max-w-[960px]">
6666
<div>
6767
<p className="mt-8 text-lg">
6868
Click on the <code>uid</code> to display the relevant data for that
@@ -88,9 +88,11 @@ function App() {
8888
</ul>
8989
))}
9090
</div>
91-
<div className="sticky top-0">
92-
<h1 className="font-bold mb-4">User data</h1>
93-
<div>{renderUserData()}</div>
91+
<div>
92+
<div className="sticky top-10">
93+
<h1 className="font-bold mb-4">User data</h1>
94+
<div>{renderUserData()}</div>
95+
</div>
9496
</div>
9597
</div>
9698
</div>

0 commit comments

Comments
 (0)