-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
- Loading branch information
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
build-base: |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
FROM python:3.10-buster | ||
|
||
RUN curl -sSL https://install.python-poetry.org | python3 - | ||
|
||
RUN ["mkdir", "/app"] | ||
WORKDIR /app | ||
|
||
COPY . /app | ||
|
||
RUN ["/root/.local/bin/poetry", "install"] | ||
ENTRYPOINT ["/root/.local/bin/poetry", "run", "python", "-m", "remarks"] |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
FROM laauurraaa/remarks-bin:0.3.16 | ||
|
||
COPY server.py /app/server.py | ||
RUN ["/root/.local/bin/poetry", "run", "pip", "install", "flask"] | ||
|
||
ENTRYPOINT ["/root/.local/bin/poetry", "run", "python", "/app/server.py"] |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
from flask import Flask, request, jsonify | ||
from remarks import remarks | ||
import os, os.path | ||
|
||
default_args = { | ||
"file_name": None, | ||
"ann_type": ["scribbles", "highlights"], | ||
"combined_pdf": True, | ||
"combined_md": True, | ||
"modified_pdf": False, | ||
"md_hl_format": "whole_block", | ||
"md_page_offset": 0, | ||
"md_header_format": "atx", | ||
"per_page_targets": [], | ||
"assume_malformed_pdfs": False, | ||
"avoid_ocr": False, | ||
} | ||
|
||
app = Flask("Remarks http server") | ||
|
||
@app.post("/process") | ||
def process(): | ||
params = request.get_json() | ||
|
||
assert 'in_path' in params, "Missing parameter: in_path" | ||
assert 'out_path' in params, "Missing parameter: out_path" | ||
|
||
in_path = params['in_path'] | ||
out_path = params['out_path'] | ||
|
||
assert os.path.exists(in_path), f"Path does not exist: {in_path}" | ||
assert os.path.exists(out_path), f"Path does not exist: {out_path}" | ||
|
||
print(f"Got a request to process {params['in_path']}") | ||
|
||
parent_dir = in_path | ||
for i in range(1): | ||
parent_dir = os.path.dirname(parent_dir) | ||
out_dir = os.path.join(parent_dir, "out") | ||
|
||
print(f"Making directory {out_dir}") | ||
os.makedirs(out_dir) | ||
|
||
result = remarks.run_remarks(in_path, out_dir, **default_args) | ||
|
||
return "OK" | ||
|
||
|
||
app.run(host="0.0.0.0", port=5000) |