Revision 61719
Added by Sandro La Bruzzo over 1 year ago
modules/dli-service-portal/branches/ES_7/main.py | ||
---|---|---|
1 | 1 |
import os |
2 | 2 |
from fastapi import FastAPI, Form |
3 |
from fastapi.responses import PlainTextResponse |
|
3 | 4 |
import logging |
4 | 5 |
from starlette.staticfiles import StaticFiles |
5 | 6 |
from starlette.responses import FileResponse |
... | ... | |
60 | 61 |
def favicon(): |
61 | 62 |
return FileResponse(os.path.join(os.path.join(_CURDIR, 'static' ),'favicon.ico')) |
62 | 63 |
|
64 |
|
|
65 |
|
|
66 |
|
|
67 |
@app.get("/api/metrics", response_class=PlainTextResponse) |
|
68 |
def main_page_stats(): |
|
69 |
connector= DLIESConnector() |
|
70 |
data =dict(result=connector.get_main_page_stats()) |
|
71 |
print(data) |
|
72 |
output ="""# TYPE scholexplorer_indexed_datasets gauge\nscholexplorer_indexed_datasets {}\n# TYPE scholexplorer_indexed_publications gauge\nscholexplorer_indexed_publications {}\n# TYPE scholexplorer_indexed_relations gauge\nscholexplorer_indexed_relations {}""".format(data['result']['dataset'], data['result']['publication'], data['result']['total']) |
|
73 |
return output |
|
74 |
|
|
75 |
|
|
76 |
|
|
77 |
|
|
63 | 78 |
@app.get("/api/main_page_stats") |
64 | 79 |
def main_page_stats(): |
65 | 80 |
connector= DLIESConnector() |
modules/dli-service-portal/branches/ES_7/requirements.txt | ||
---|---|---|
5 | 5 |
elasticsearch==7.5.1 |
6 | 6 |
elasticsearch-dsl==7.1.0 |
7 | 7 |
fastapi==0.20.0 |
8 |
fastapi-responses==0.2.1 |
|
8 | 9 |
h11==0.8.1 |
9 | 10 |
httptools==0.0.13 |
10 | 11 |
idna==2.8 |
modules/dli-service-portal/branches/ES_7/static/partials/query.html | ||
---|---|---|
136 | 136 |
|
137 | 137 |
<div class="row" ng-repeat="result in result_query"> |
138 | 138 |
<div class="col-lg-12" style="margin-top: 10px"> |
139 |
<span class="label label-info" style="font-size: 100%">{{ result.typology }}</span>
|
|
139 |
<span class="label label-info" style="font-size: 100%">{{ result.subType }}</span>
|
|
140 | 140 |
<span ng-repeat="date in showDate(result.date)" class="label label-warning" |
141 | 141 |
style="font-size: 100%"> {{ date }}</span> |
142 | 142 |
</div> |
Also available in: Unified diff
implemented api entry to return metrics in prometheus format