-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
93 lines (68 loc) · 2.1 KB
/
main.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
82
83
84
85
86
87
88
89
90
91
92
import json
from fastapi import FastAPI
from pydantic import BaseModel
import authentication
import post
import user
app = FastAPI()
class Credentials(BaseModel):
pseudo: str
code: str
class Poster(BaseModel):
message : str
senderPseudo : str
class Search(BaseModel):
research : str
class Follow(BaseModel):
followed : str
follower : str
class LikePost(BaseModel):
pseudo : str
author : str
creation : float
@app.get("/")
def read_root():
return {"Hello": "World"}
@app.post("/signUp")
def read_root(credentials: Credentials):
test = authentication.signUp(credentials.pseudo, credentials.code)
return json.dumps(test)
@app.post("/signIn")
def read_root(credentials: Credentials):
return authentication.signIn(credentials.pseudo, credentials.code)
@app.post("/post")
def read_root(poster: Poster):
return post.createPost(poster.message, poster.senderPseudo)
@app.post("/users")
def read_root(search : Search):
return user.findAll(search.research)
@app.post("/user")
def read_root(pseudo : Search):
return user.findOne(pseudo.research)
@app.get("/")
def read_root():
return "Hello World"
@app.put('/follow')
def read_root(follow : Follow):
return user.followOne(follow.follower, follow.followed)
@app.put('/unfollow')
def read_root(follow : Follow):
return user.unfollowOne(follow.follower, follow.followed)
@app.post('/verifyFollow')
def read_root(follow : Follow):
return user.verifyFollow(follow.follower, follow.followed)
@app.put('/like')
def read_root(likePost : LikePost):
return post.likePost(likePost.author, likePost.pseudo, likePost.creation)
@app.put('/unlike')
def read_root(likePost : LikePost):
return post.unlikePost(likePost.author, likePost.pseudo, likePost.creation)
@app.post('/verifyLike')
def read_root(likePost : LikePost):
return post.verifyLike(likePost.author, likePost.pseudo, likePost.creation)
@app.post('/postByUser')
def read_root(search : Search):
return user.getPostfromUser(search.research)
@app.post('/subscribePost')
def read_root(search : Search):
return post.getAllMyPost(search.research)