Skip to content

Commit

Permalink
feat: migrate to Flask
Browse files Browse the repository at this point in the history
  • Loading branch information
egvimo committed Oct 20, 2023
1 parent fd2dffb commit 902bad2
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 9 deletions.
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ WORKDIR /app

COPY requirements.txt app.py apt_info.py ./

RUN pip install -r requirements.txt \
RUN pip install --no-cache-dir --upgrade -r requirements.txt \
&& rm requirements.txt

EXPOSE 8000

CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--no-access-log"]
CMD ["gunicorn", "app:app", "-b", "0.0.0.0"]
9 changes: 4 additions & 5 deletions app.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
import os
from fastapi import FastAPI
from fastapi.responses import PlainTextResponse
from flask import Flask, Response
import apt_info

root_dir = os.environ.get("APT_ROOT_DIR", "/")

app = FastAPI()
app = Flask(__name__)


@app.get("/metrics", response_class=PlainTextResponse)
@app.route("/metrics")
def metrics():
data = apt_info.generate_metrics(root_dir=root_dir)
return data
return Response(data, mimetype='text/plain')
4 changes: 2 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
python-apt @ git+https://salsa.debian.org/apt-team/[email protected]
prometheus_client==0.17.1
fastapi==0.103.2
uvicorn[standard]==0.23.2
Flask==3.0.0
gunicorn==21.2.0

0 comments on commit 902bad2

Please sign in to comment.