Skip to content

Commit 166f71a

Browse files
committed
Docs and some improvements
1 parent 7b70f6a commit 166f71a

File tree

6 files changed

+88
-7
lines changed

6 files changed

+88
-7
lines changed

Dockerfile

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@ RUN pip install --no-cache-dir -r ./requirements.txt
1212

1313
COPY ./app/ ./
1414

15-
# CMD ["uvicorn", "main:app", "--host=0.0.0.0", "--reload", "--port", "8000"]
16-
1715
RUN chmod +x ./entrypoint.sh
1816

1917
ENTRYPOINT [ "./entrypoint.sh" ]
18+
# ENTRYPOINT [ "tail", "-f", "/dev/null"]

README.md

Lines changed: 81 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,81 @@
1-
# Uptime-Kuma-Web-API
1+
# Uptime-Kuma-Web-API
2+
## A REST API wrapper for [Uptime Kuma](https://github.com/louislam/uptime-kuma) using [Uptime-Kuma-API](https://github.com/lucasheld/uptime-kuma-api)
3+
---
4+
## EndPoints:
5+
6+
![Alt text](./images/1.png )
7+
![Alt text](./images/2.png )
8+
9+
10+
## How to use it:
11+
----
12+
13+
### Environment Variables :
14+
You have to define these ENV VARS in order to connect to your KUMA server.
15+
16+
KUMA_SERVER=<your_kuma_server>
17+
KUMA_USERNAME=<your_kuma_username>
18+
KUMA_PASSWORD=<your_kuma_password>
19+
ADMIN_PASSWORD=<your admin password so you can connect with via the api>
20+
21+
#### Note:
22+
23+
You have to define your ADMIN_PASSWORD or you wont be able to connect to your rest api.
24+
25+
You will connect with those credentials:
26+
27+
username = admin
28+
password = <ADMIN_PASSWORD>
29+
30+
### Features:
31+
- Multi user Kuma api ( without privilege YET!!) with a small SQLite db
32+
- Easy to use REST API with most of the Uptime-Kuma features
33+
- Swagger Docs
34+
- Dockerized [UptimeKuma_RestAPI Container](https://hub.docker.com/repository/docker/medaziz11/uptimekuma_restapi)
35+
36+
### Example :
37+
You can simply create a docker compose file like this :
38+
39+
```yaml
40+
version: '3.9'
41+
services:
42+
kuma:
43+
container_name: uptime-kuma
44+
image: louislam/uptime-kuma:latest
45+
ports:
46+
- "3001:3001"
47+
restart: always
48+
volumes:
49+
- uptime-kuma:/app/data
50+
51+
api:
52+
container_name: backend
53+
image: medaziz11/uptimekuma_restapi
54+
volumes:
55+
- ./db:/db
56+
restart: always
57+
environment:
58+
- KUMA_SERVER=http://kuma:3001
59+
- KUMA_USERNAME=test
60+
- KUMA_PASSWORD=123test.
61+
- ADMIN_PASSWORD=admin
62+
depends_on:
63+
- kuma
64+
ports:
65+
- "8000:8000"
66+
67+
volumes:
68+
uptime-kuma:
69+
```
70+
### In order for the example to work: You have to run kuma first then create your kuma username and password then re-run the compose file.
71+
72+
### Example CURL Script:
73+
---
74+
75+
```bash
76+
77+
TOKEN=$(curl -X 'POST' -H 'Content-Type: application/x-www-form-urlencoded' --data 'username=admin&password=admin' http://127.0.0.1:8000/login/access-token/ | jq -r ".access_token")
78+
79+
curl -H 'Accept: application/json' -H "Authorization: Bearer ${TOKEN}" http://127.0.0.1:8000/monitors/
80+
81+
```

app/main.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
from fastapi import FastAPI
2+
from fastapi.responses import RedirectResponse
23
import os
34

45
from routers import monitor, auth, tags, cert, info, uptime, ping, database, settings as settings, user
@@ -45,6 +46,6 @@ async def startup_event():
4546
async def shutdown_event():
4647
await Tortoise.close_connections()
4748

48-
@app.get("/")
49+
@app.get("/", include_in_schema=False)
4950
async def root():
50-
return {"Foo": "Bar"}
51+
return RedirectResponse(url='/docs')

docker-compose.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,19 @@ services:
1111

1212
api:
1313
container_name: backend
14-
build: .
14+
image: medaziz11/uptimekuma_restapi
1515
volumes:
1616
- ./db:/db
1717
restart: always
1818
environment:
19-
- PORT=8080
2019
- KUMA_SERVER=http://kuma:3001
2120
- KUMA_USERNAME=test
2221
- KUMA_PASSWORD=123test.
2322
- ADMIN_PASSWORD=admin
2423
depends_on:
2524
- kuma
25+
ports:
26+
- "8000:8000"
2627

2728
volumes:
2829
uptime-kuma:

images/1.png

65.6 KB
Loading

images/2.png

63.3 KB
Loading

0 commit comments

Comments
 (0)