Compare commits
5 Commits
1.0.0
...
86a03647df
| Author | SHA1 | Date | |
|---|---|---|---|
| 86a03647df | |||
| 73da634029 | |||
| 9424276474 | |||
| 7949312f9a | |||
| f814a1ba00 |
@ -2,10 +2,12 @@ FROM python:3.13-slim
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
COPY . .
|
||||
|
||||
RUN apt-get update && apt-get install -y --no-install-recommends libpq-dev build-essential
|
||||
|
||||
COPY requirements.txt ./
|
||||
|
||||
RUN pip install --no-cache-dir -r requirements.txt
|
||||
|
||||
COPY . .
|
||||
|
||||
CMD ["python", "src/main.py"]
|
||||
|
||||
@ -11,6 +11,7 @@ router = APIRouter(prefix='/api')
|
||||
|
||||
|
||||
class Entry(BaseModel):
|
||||
username: str
|
||||
url: str
|
||||
rating: int | None = None
|
||||
|
||||
@ -47,6 +48,7 @@ async def save_rating(entry: Entry, response: Response):
|
||||
message = 'internal server error'
|
||||
finally:
|
||||
return {'message': message,
|
||||
'username': entry.username,
|
||||
'url': entry.url,
|
||||
'rating': entry.rating
|
||||
}
|
||||
@ -68,14 +70,14 @@ async def remove_rating(entry: Entry, response: Response):
|
||||
async def get_article_html(article: Article, response: Response = None):
|
||||
html_string = await scraper.get_article_html(article.url)
|
||||
b64_string = base64.b64encode(html_string.encode('utf-8')).decode('utf-8')
|
||||
return Response(content=article.url + '\r\n' + b64_string, media_type='text/plain')
|
||||
return {article.url: b64_string}
|
||||
|
||||
|
||||
@router.post('/article/get/md')
|
||||
async def get_article_md(article: Article, response: Response = None):
|
||||
md_string = await scraper.get_article_html(article.url, md=True)
|
||||
b64_string = base64.b64encode(md_string.encode('utf-8')).decode('utf-8')
|
||||
return Response(content=article.url + '\r\n' + b64_string, media_type='text/plain')
|
||||
return {article.url: b64_string}
|
||||
|
||||
|
||||
@router.post('/articles/get/html')
|
||||
|
||||
Reference in New Issue
Block a user