File tree 3 files changed +21
-3
lines changed
3 files changed +21
-3
lines changed Original file line number Diff line number Diff line change @@ -17,7 +17,7 @@ It's not required but you can use it if you need multiple-platform requests (ex.
17
17
### Steps
18
18
19
19
1 . Create ` fork ` .
20
- 2 . Add your username in ` usernames .json` in format below:
20
+ 2 . Add your username in ` users .json` in format below:
21
21
``` json
22
22
{
23
23
"USERNAME_YOU_NEED*" : {
Original file line number Diff line number Diff line change @@ -55,4 +55,22 @@ def get_leetcode_info(username: str):
55
55
56
56
@app .get ("/status" )
57
57
def get_status ():
58
- return json .load (open ("status.json" , "r" ))
58
+ return json .load (open ("status.json" , "r" ))
59
+
60
+ @app .get ("/{username}" )
61
+ def get_all_ratings_from_username (username : str ):
62
+ with open ('users.json' ) as file :
63
+ users : dict = json .load (file )
64
+ if username in users .keys ():
65
+ userdata = users [username ]
66
+ else :
67
+ return {"error" : "username not found!" ,
68
+ "code" : 1001 }
69
+
70
+ body = {}
71
+ if "leetcode" in userdata .keys ():
72
+ body ['leetcode' ] = get_leetcode_info (userdata ['leetcode' ]) # TODO: use better functions
73
+ if "codeforces" in userdata .keys ():
74
+ body ['codeforces' ] = get_codeforces_info (userdata ['codeforces' ]) # TODO: use better functions
75
+
76
+ return body
Original file line number Diff line number Diff line change 1
1
{
2
- "jayampatel" : {
2
+ "@ jayampatel" : {
3
3
"github" : " jayam04" ,
4
4
"leetcode" : " jayampatel" ,
5
5
"codeforces" : " jayampatel"
You can’t perform that action at this time.
0 commit comments