43 lines
1.1 KiB
Python
43 lines
1.1 KiB
Python
from fastapi import FastAPI
|
|
|
|
import db
|
|
|
|
app = FastAPI()
|
|
|
|
|
|
@app.get("/")
|
|
async def root():
|
|
return {"message": "Hello World"}
|
|
|
|
|
|
@app.get("/hello/{name}")
|
|
async def say_hello(name: str):
|
|
return {"message": f"Hello {name}"}
|
|
|
|
@app.get("/test/{name}+{name2}")
|
|
async def say_hello(name: str, name2: str):
|
|
return {"message": f"Hello {name}. Or are you known as {name2}?"}
|
|
|
|
@app.get("/createEndpoint/{username}+{context}+{password}")
|
|
async def createEndpoint(username: str, context: str, password: str):
|
|
db.create_Endpoint(username, context, password)
|
|
return {"message": f"{username}, {context}, {password}"}
|
|
|
|
@app.get("/deleteEndpoint/{username}")
|
|
async def deleteEndpoint(username: str):
|
|
db.delete_Endpoint(username)
|
|
return {"message": f"{username}"}
|
|
|
|
@app.get("/updatePassword/{username}+{password}")
|
|
async def updatePassword(username: str, password: str):
|
|
db.update_Password(username, password)
|
|
return {"message": f"{username}"}
|
|
|
|
@app.get("/getUsers/")
|
|
async def getUsers():
|
|
all=[]
|
|
users=db.getUsers()
|
|
for each in users:
|
|
all.append(each[0])
|
|
print(all)
|
|
return {"message": f"{all}"} |