forked from oscar.krause/fastapi-dls
added some new endpoints and links in readme
This commit is contained in:
parent
ed1b55f5f1
commit
a09fc5f2ad
@ -75,7 +75,7 @@ if [[ -f $CONFIG_DIR/webserver.key ]]; then
|
||||
if [ -x "$(command -v curl)" ]; then
|
||||
echo "> Testing API ..."
|
||||
source $CONFIG_DIR/env
|
||||
curl --insecure -X GET https://$DLS_URL:$DLS_PORT/status
|
||||
curl --insecure -X GET https://$DLS_URL:$DLS_PORT/-/health
|
||||
else
|
||||
echo "> Testing API failed, curl not available. Please test manually!"
|
||||
fi
|
||||
|
@ -122,7 +122,7 @@ test:
|
||||
- FASTAPI_DLS_PID=$!
|
||||
- echo "Started service with pid $FASTAPI_DLS_PID"
|
||||
# testing service
|
||||
- if [ "`curl --insecure -s https://127.0.0.1/status | jq .status`" != "up" ]; then echo "Success"; else "Error"; fi
|
||||
- if [ "`curl --insecure -s https://127.0.0.1/-/health | jq .status`" != "up" ]; then echo "Success"; else "Error"; fi
|
||||
# cleanup
|
||||
- kill $FASTAPI_DLS_PID
|
||||
- apt-get purge -qq -y fastapi-dls
|
||||
|
@ -14,5 +14,5 @@ COPY app /app
|
||||
COPY version.env /version.env
|
||||
COPY README.md /README.md
|
||||
|
||||
HEALTHCHECK --start-period=30s --interval=10s --timeout=5s --retries=3 CMD curl --insecure --fail https://localhost/status || exit 1
|
||||
HEALTHCHECK --start-period=30s --interval=10s --timeout=5s --retries=3 CMD curl --insecure --fail https://localhost/-/health || exit 1
|
||||
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "443", "--app-dir", "/app", "--proxy-headers", "--ssl-keyfile", "/app/cert/webserver.key", "--ssl-certfile", "/app/cert/webserver.crt"]
|
||||
|
21
README.md
21
README.md
@ -13,19 +13,27 @@ Only the clients need a connection to this service on configured port.
|
||||
|
||||
## Endpoints
|
||||
|
||||
### `GET /`
|
||||
### [`GET /`](/)
|
||||
|
||||
HTML rendered README.md.
|
||||
Redirect to `/-/readme`.
|
||||
|
||||
### `GET /status`
|
||||
### [`GET /status`](/status) (deprecated: use `/-/health`)
|
||||
|
||||
Status endpoint, used for *healthcheck*. Shows also current version and commit hash.
|
||||
|
||||
### `GET /docs`
|
||||
### [`GET /-/health`](/-/health)
|
||||
|
||||
OpenAPI specifications rendered from `GET /openapi.json`.
|
||||
Status endpoint, used for *healthcheck*. Shows also current version and commit hash.
|
||||
|
||||
### `GET /-/manage`
|
||||
### [`GET /-/readme`](/-/readme)
|
||||
|
||||
HTML rendered README.md.
|
||||
|
||||
### [`GET /-/docs`](/-/docs), [`GET /-/redocs`](/-/redocs)
|
||||
|
||||
OpenAPI specifications rendered from `GET /-/openapi.json`.
|
||||
|
||||
### [`GET /-/manage`](/-/manage)
|
||||
|
||||
Shows a very basic UI to delete origins or leases.
|
||||
|
||||
@ -413,7 +421,6 @@ Dec 20 17:53:34 ubuntu-grid-server nvidia-gridd[10354]: License acquired success
|
||||
|
||||
</details>
|
||||
|
||||
|
||||
# Credits
|
||||
|
||||
Thanks to vGPU community and all who uses this project and report bugs.
|
||||
|
24
app/main.py
24
app/main.py
@ -63,19 +63,29 @@ def get_token(request: Request) -> dict:
|
||||
return jwt.decode(token=token, key=jwt_decode_key, algorithms=ALGORITHMS.RS256, options={'verify_aud': False})
|
||||
|
||||
|
||||
@app.get('/')
|
||||
@app.get('/', summary='* Index')
|
||||
async def index():
|
||||
return RedirectResponse('/-/readme')
|
||||
|
||||
|
||||
@app.get('/status', summary='* Status', description='Returns current service status, version (incl. git-commit) and some variables.', deprecated=True)
|
||||
async def status(request: Request):
|
||||
return JSONResponse({'status': 'up', 'version': VERSION, 'commit': COMMIT, 'debug': DEBUG})
|
||||
|
||||
|
||||
@app.get('/-/health', summary='* Health')
|
||||
async def _health(request: Request):
|
||||
return JSONResponse({'status': 'up', 'version': VERSION, 'commit': COMMIT, 'debug': DEBUG})
|
||||
|
||||
|
||||
@app.get('/-/readme', summary='* Readme')
|
||||
async def _readme():
|
||||
from markdown import markdown
|
||||
content = load_file('../README.md').decode('utf-8')
|
||||
return HTMLResponse(markdown(text=content, extensions=['tables', 'fenced_code', 'md_in_html', 'nl2br', 'toc']))
|
||||
|
||||
|
||||
@app.get('/status')
|
||||
async def status(request: Request):
|
||||
return JSONResponse({'status': 'up', 'version': VERSION, 'commit': COMMIT, 'debug': DEBUG})
|
||||
|
||||
|
||||
@app.get('/-/manage')
|
||||
@app.get('/-/manage', summary='* Management UI')
|
||||
async def _manage(request: Request):
|
||||
response = '''
|
||||
<!DOCTYPE html>
|
||||
|
Loading…
Reference in New Issue
Block a user