add: display home markdown

This commit is contained in:
h z
2024-12-09 21:15:04 +00:00
parent 038efb745a
commit 797bf65d4e
4 changed files with 32 additions and 13 deletions

8
.dockerignore Normal file
View File

@@ -0,0 +1,8 @@
__pycache__
*.pyc
*.pyo
*.pyd
.git
.env
tests/
docs/

View File

@@ -1,20 +1,15 @@
FROM python:3.12-slim
ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONUNBUFFERED 1
WORKDIR /app
RUN apt-get update &&\
apt-get install -y \
default-mysql-client &&\
apt-get clean
COPY requirements.txt /app/
RUN pip install --no-cache-dir -r requirements.txt
apt-get install -y default-mysql-client &&\
apt-get clean &&\
rm -rf /var/lib/apt/lists/*
COPY requirements.txt ./requirements.txt
RUN pip install --no-cache-dir -r ./requirements.txt
COPY . /app/
EXPOSE 5000
CMD ["python", "app.py"]
CMD ["python", "app.py"]

View File

@@ -1,6 +1,4 @@
#api/markdown.py
from flask import Blueprint, request, jsonify
import api
from api import require_auth, etag_response
from contexts.RequestContext import RequestContext
@@ -20,6 +18,15 @@ def get_markdowns():
mds = session.query(Markdown).all()
return jsonify([md.to_dict() for md in mds]), 200
@markdown_bp.route('/get_home', methods=['GET'])
@limiter.limit(api.get_rate_limit)
@etag_response
def get_home():
with get_db() as session:
markdown = session.query(Markdown).filter(Markdown.path_id == 1).filter(Markdown.title == "index").first()
if markdown is None:
return jsonify({}), 204
return jsonify(markdown.to_dict()), 200
@markdown_bp.route('/by_path/<int:path_id>', methods=['GET'])
@limiter.limit(api.get_rate_limit)
@etag_response

9
req2.txt Normal file
View File

@@ -0,0 +1,9 @@
cryptography==44.0.0
Flask==3.1.0
Flask_Cors==5.0.0
Flask_Limiter==3.9.2
PyJWT==2.10.1
PyJWT==2.10.1
python-dotenv==1.0.1
Requests==2.32.3
SQLAlchemy==2.0.36