Add frontend

This commit is contained in:
Nikiroy78 2023-10-02 12:42:57 +03:00
parent 4f0bd8670b
commit c47b7334eb
2 changed files with 23 additions and 7 deletions

View File

@ -2,32 +2,48 @@ import requests as req
class CreateItemChecks: class CreateItemChecks:
def createAuthor (result): def createAuthor (this, result):
return 'response' in result
def invalidType (this, result):
return 'response' in result return 'response' in result
class CreateItemActions: class CreateItemActions:
def createAuthor (): def createAuthor (this):
return req.post( return req.post(
"http://127.0.0.1:8080/api/v/1.0/create-item?response_format=json", "http://127.0.0.1:8080/api/v/1.0/create-item?response_format=json",
json={ json={
"type" : "author" "type" : "author",
"name" : "TestAuthor"
}
).json()
def invalidType (this):
return req.post(
"http://127.0.0.1:8080/api/v/1.0/create-item?response_format=json",
json={
"type" : "asdasdsad",
"name" : "TestAuthor"
} }
).json() ).json()
createItemActions = CreateItemActions() createItemActions = CreateItemActions()
createItemChecks = CreateItemChecks() createItemChecks = CreateItemChecks()
def test (id, action, isDone): def test (id, action, isDone, nextTest=lambda:None):
try: try:
print("""Test {id} runned..""") print("""Test {id} runned..""")
result = action() result = action()
if isDone(result): if isDone(result):
print("""Test {id} success!""") print("""Test {id} success!""")
nextTest()
else: else:
print("""Test {id} ERROR""") print("""Test {id} ERROR""")
print(result) print(result)
except Exception as exc: except Exception as exc:
print(exc) print(exc)
test(1, createItemActions.createAuthor, createItemChecks.createAuthor) test_3 = lambda : test(3, createItemActions.createAuthor, createItemChecks.createAuthor)
test_2 = lambda : test(2, createItemActions.createAuthor, createItemChecks.createAuthor)
test_1 = test(1, createItemActions.invalidType, createItemChecks.invalidType, test)

View File

@ -64,8 +64,8 @@ app.use((req, res, next) => {
); );
}); });
app.use("/", async (rq, rs, next) => next(), require("./page-view")); app.use("/", require("./page-view"));
app.use("/api", async (rq, rs, next) => next(), require("./api")); app.use("/api", require("./api"));
// Подключение через HTTPS // Подключение через HTTPS
let server; let server;