Refactored dependencies description, switched from flake8 to pylint in format gh action
This commit is contained in:
parent
5155790357
commit
a52520c4e2
8
.github/workflows/format.yml
vendored
8
.github/workflows/format.yml
vendored
@ -19,12 +19,10 @@ jobs:
|
|||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
run: |
|
run: |
|
||||||
python -m pip install --upgrade pip
|
python -m pip install --upgrade pip
|
||||||
pip install flake8 black
|
pip install -r requirements/dev.txt
|
||||||
|
|
||||||
- name: Lint with flake8
|
- name: Lint with pylint
|
||||||
run: |
|
run: pylint app --extension-pkg-allow-list=lxml
|
||||||
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
|
|
||||||
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
|
|
||||||
|
|
||||||
- name: Format with black
|
- name: Format with black
|
||||||
run: black .
|
run: black .
|
||||||
|
@ -2,9 +2,9 @@ FROM python
|
|||||||
|
|
||||||
WORKDIR /srv
|
WORKDIR /srv
|
||||||
|
|
||||||
COPY ./requirements.txt /srv/requirements.txt
|
COPY ./requirements /srv/requirements
|
||||||
|
|
||||||
RUN pip install -r requirements.txt
|
RUN pip install -r requirements/prod.txt
|
||||||
|
|
||||||
EXPOSE 80
|
EXPOSE 80
|
||||||
|
|
||||||
|
29
README.md
29
README.md
@ -10,10 +10,35 @@ Backend for online ebook viewer publite
|
|||||||
|
|
||||||
## Deploy
|
## Deploy
|
||||||
|
|
||||||
|
Run app locally (development only!)
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# install requirements
|
||||||
|
pip install -r requirements/dev.txt
|
||||||
|
|
||||||
|
# run app with uvicorn
|
||||||
|
uvicorn app.main:app --reload --port <port>
|
||||||
|
```
|
||||||
|
|
||||||
|
Run app locally (test prod)
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# install requirements
|
||||||
|
pip install -r requirements/prod.txt
|
||||||
|
|
||||||
|
# run app with uvicorn
|
||||||
|
uvicorn app.main:app --port <port>
|
||||||
|
|
||||||
|
# or
|
||||||
|
|
||||||
|
# run with python script
|
||||||
|
python run.py
|
||||||
|
```
|
||||||
|
|
||||||
Simple docker deployment
|
Simple docker deployment
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
# build docker image
|
# build docker image
|
||||||
docker build . -t publite_backend
|
docker build . -t publite_backend
|
||||||
|
|
||||||
# run it with docker
|
# run it with docker
|
||||||
@ -25,4 +50,4 @@ Dokku deployment with image from Docker Hub
|
|||||||
```bash
|
```bash
|
||||||
dokku apps:create publitebackend
|
dokku apps:create publitebackend
|
||||||
dokku git:from-image publitebackend publite/backend:latest
|
dokku git:from-image publitebackend publite/backend:latest
|
||||||
```
|
```
|
||||||
|
0
app/__init__.py
Normal file
0
app/__init__.py
Normal file
10
app/epub.py
10
app/epub.py
@ -2,19 +2,19 @@
|
|||||||
Module for EPUB file conversion to html
|
Module for EPUB file conversion to html
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from base64 import b64encode
|
|
||||||
from functools import cache
|
|
||||||
import html
|
import html
|
||||||
import os
|
import os
|
||||||
|
from base64 import b64encode
|
||||||
|
from functools import cache
|
||||||
from tempfile import SpooledTemporaryFile
|
from tempfile import SpooledTemporaryFile
|
||||||
|
|
||||||
import aiofiles as aiof
|
import aiofiles as aiof
|
||||||
from fastapi import HTTPException
|
|
||||||
from lxml import etree
|
|
||||||
import ebooklib
|
import ebooklib
|
||||||
from ebooklib import epub
|
from ebooklib import epub
|
||||||
|
from fastapi import HTTPException
|
||||||
|
from lxml import etree
|
||||||
|
|
||||||
from .utils import DocumentTokens, strip_whitespace, HTMLBook
|
from .utils import DocumentTokens, HTMLBook, strip_whitespace
|
||||||
|
|
||||||
parser = etree.XMLParser(recover=True)
|
parser = etree.XMLParser(recover=True)
|
||||||
|
|
||||||
|
11
app/fb2.py
11
app/fb2.py
@ -2,16 +2,15 @@
|
|||||||
Module for FB2 file conversion to html
|
Module for FB2 file conversion to html
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from tempfile import SpooledTemporaryFile
|
|
||||||
import xml.etree.ElementTree as ET
|
|
||||||
from xml.etree.ElementTree import Element
|
|
||||||
from typing import Optional
|
|
||||||
import html
|
import html
|
||||||
|
import xml.etree.ElementTree as ET
|
||||||
|
from tempfile import SpooledTemporaryFile
|
||||||
|
from typing import Optional
|
||||||
|
from xml.etree.ElementTree import Element
|
||||||
|
|
||||||
from fastapi import HTTPException
|
from fastapi import HTTPException
|
||||||
|
|
||||||
from .utils import DocumentTokens, strip_whitespace, HTMLBook
|
from .utils import DocumentTokens, HTMLBook, strip_whitespace
|
||||||
|
|
||||||
|
|
||||||
namespaces = {
|
namespaces = {
|
||||||
"": "http://www.gribuser.ru/xml/fictionbook/2.0",
|
"": "http://www.gribuser.ru/xml/fictionbook/2.0",
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
|
||||||
from fastapi import FastAPI, File, UploadFile, HTTPException
|
from fastapi import FastAPI, File, HTTPException, UploadFile
|
||||||
from pydantic import BaseModel # pylint: disable=no-name-in-module
|
from pydantic import BaseModel # pylint: disable=no-name-in-module
|
||||||
|
|
||||||
from .epub import epub2html
|
from .epub import epub2html
|
||||||
|
@ -3,9 +3,9 @@ Utils for publite_backend module
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
||||||
from typing import Union, Optional
|
|
||||||
import re
|
import re
|
||||||
from hashlib import sha256
|
from hashlib import sha256
|
||||||
|
from typing import Optional, Union
|
||||||
|
|
||||||
from pydantic import BaseModel # pylint: disable=no-name-in-module
|
from pydantic import BaseModel # pylint: disable=no-name-in-module
|
||||||
|
|
||||||
|
@ -1,23 +1 @@
|
|||||||
aiofiles==0.7.0
|
-r requirements/prod.txt
|
||||||
appdirs==1.4.4
|
|
||||||
asgiref==3.4.0
|
|
||||||
black==21.6b0
|
|
||||||
click==8.0.1
|
|
||||||
EbookLib==0.17.1
|
|
||||||
fastapi==0.65.2
|
|
||||||
flake8==3.9.2
|
|
||||||
h11==0.12.0
|
|
||||||
lxml==4.6.3
|
|
||||||
mccabe==0.6.1
|
|
||||||
mypy-extensions==0.4.3
|
|
||||||
pathspec==0.8.1
|
|
||||||
pycodestyle==2.7.0
|
|
||||||
pydantic==1.8.2
|
|
||||||
pyflakes==2.3.1
|
|
||||||
python-multipart==0.0.5
|
|
||||||
regex==2021.7.1
|
|
||||||
six==1.16.0
|
|
||||||
starlette==0.14.2
|
|
||||||
toml==0.10.2
|
|
||||||
typing-extensions==3.10.0.0
|
|
||||||
uvicorn==0.14.0
|
|
4
requirements/dev.txt
Normal file
4
requirements/dev.txt
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
-r prod.txt
|
||||||
|
pylint
|
||||||
|
rope
|
||||||
|
black
|
7
requirements/prod.txt
Normal file
7
requirements/prod.txt
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
fastapi
|
||||||
|
uvicorn
|
||||||
|
aiofiles
|
||||||
|
ebooklib
|
||||||
|
python-multipart
|
||||||
|
lxml
|
||||||
|
pydantic
|
Loading…
x
Reference in New Issue
Block a user