Spaces:
Running
Running
st4ck commited on
Commit ·
3d052c5
1
Parent(s): 3d532ae
Switch to gunicorn, add /health endpoint
Browse files- Dockerfile +2 -2
- app.py +5 -1
Dockerfile
CHANGED
|
@@ -8,8 +8,8 @@ COPY . .
|
|
| 8 |
# Pre-compile the binary at image build time
|
| 9 |
RUN gcc -O2 -o mdc mdc.c -lm
|
| 10 |
|
| 11 |
-
RUN pip install --no-cache-dir flask
|
| 12 |
|
| 13 |
EXPOSE 7860
|
| 14 |
|
| 15 |
-
CMD ["
|
|
|
|
| 8 |
# Pre-compile the binary at image build time
|
| 9 |
RUN gcc -O2 -o mdc mdc.c -lm
|
| 10 |
|
| 11 |
+
RUN pip install --no-cache-dir flask gunicorn
|
| 12 |
|
| 13 |
EXPOSE 7860
|
| 14 |
|
| 15 |
+
CMD ["gunicorn", "--bind", "0.0.0.0:7860", "--workers", "2", "--timeout", "120", "app:app"]
|
app.py
CHANGED
|
@@ -77,6 +77,11 @@ def fmt(n):
|
|
| 77 |
return f"{n/1024**2:.2f} MB"
|
| 78 |
|
| 79 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 80 |
@app.route("/")
|
| 81 |
def index():
|
| 82 |
return render_template_string(HTML)
|
|
@@ -129,5 +134,4 @@ def decompress():
|
|
| 129 |
|
| 130 |
|
| 131 |
if __name__ == "__main__":
|
| 132 |
-
print("Starting Midicoth server on 0.0.0.0:7860", flush=True)
|
| 133 |
app.run(host="0.0.0.0", port=7860, debug=False)
|
|
|
|
| 77 |
return f"{n/1024**2:.2f} MB"
|
| 78 |
|
| 79 |
|
| 80 |
+
@app.route("/health")
|
| 81 |
+
def health():
|
| 82 |
+
return "ok", 200
|
| 83 |
+
|
| 84 |
+
|
| 85 |
@app.route("/")
|
| 86 |
def index():
|
| 87 |
return render_template_string(HTML)
|
|
|
|
| 134 |
|
| 135 |
|
| 136 |
if __name__ == "__main__":
|
|
|
|
| 137 |
app.run(host="0.0.0.0", port=7860, debug=False)
|