Initial commit. Connects to Asterisk database and API endponts setup to create endpoints, delete endpoints, update passwords, and get array of users.
This commit is contained in:
43
main.py
Normal file
43
main.py
Normal file
@@ -0,0 +1,43 @@
|
||||
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}"}
|
||||
Reference in New Issue
Block a user