diff --git a/.dockerignore b/.dockerignore deleted file mode 100644 index 55c1997..0000000 --- a/.dockerignore +++ /dev/null @@ -1,10 +0,0 @@ -.idea -.venv -.db -.env -.git -build -dist -*.egg* -__pycache__ -test.py diff --git a/Dockerfile b/Dockerfile index d62feaa..2d8c2f7 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,10 +2,12 @@ FROM python:slim ENV DEBIAN_FRONTEND noninteractive ENV LANG C.UTF-8 -COPY . /app +COPY pynyaata /app/pynyaata +COPY requirements.txt /app +COPY run.py /app WORKDIR /app RUN apt-get update && apt-get -y upgrade && apt-get -y install locales && \ printf "en_US.UTF-8 UTF-8\nfr_FR.UTF-8 UTF-8\n" > /etc/locale.gen && \ locale-gen && rm -rf /var/lib/apt/lists/* && \ pip install -r requirements.txt -CMD ["python", "app.py"] +CMD ["python", "run.py"] diff --git a/docker-compose.yml b/docker-compose.yml index 1756fa8..55dedfd 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -5,7 +5,7 @@ services: build: . ports: - "5000:5000" - entrypoint: python3 app.py + entrypoint: python3 run.py working_dir: /app depends_on: - db diff --git a/pynyaata/__init__.py b/pynyaata/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/app.py b/pynyaata/app.py similarity index 93% rename from app.py rename to pynyaata/app.py index 2bb73bc..a1ea9f4 100644 --- a/app.py +++ b/pynyaata/app.py @@ -1,15 +1,14 @@ from operator import attrgetter, itemgetter -from time import sleep from flask import redirect, render_template, request, url_for, abort -from config import app, auth, ADMIN_USERNAME, ADMIN_PASSWORD, APP_PORT -from connectors import * -from forms import SearchForm, DeleteForm, EditForm +from pynyaata.config import app, auth, ADMIN_USERNAME, ADMIN_PASSWORD +from pynyaata.connectors import * +from pynyaata.forms import SearchForm, DeleteForm, EditForm if MYSQL_ENABLED: - from config import db - from models import AnimeFolder, AnimeTitle, AnimeLink + from pynyaata.config import db + from pynyaata.models import AnimeFolder, AnimeTitle, AnimeLink def clean_model(obj): @@ -197,13 +196,3 @@ def admin_edit(link_id=None): link.vf = False return render_template('admin/edit.html', search_form=SearchForm(), link=link, folders=folders, action_form=form) - - -if __name__ == '__main__': - while True: - try: - app.run('0.0.0.0', APP_PORT, IS_DEBUG) - except Exception as e: - getLogger().exception(e) - sleep(10) - pass diff --git a/config.py b/pynyaata/config.py similarity index 100% rename from config.py rename to pynyaata/config.py diff --git a/connectors.py b/pynyaata/connectors.py similarity index 99% rename from connectors.py rename to pynyaata/connectors.py index 69fcd50..07952e2 100644 --- a/connectors.py +++ b/pynyaata/connectors.py @@ -11,7 +11,7 @@ from bs4 import BeautifulSoup from cloudscraper import create_scraper from requests import RequestException -from config import IS_DEBUG, MYSQL_ENABLED, CACHE_TIMEOUT, BLACKLIST_WORDS +from pynyaata.config import IS_DEBUG, MYSQL_ENABLED, CACHE_TIMEOUT, BLACKLIST_WORDS scraper = create_scraper() @@ -103,7 +103,7 @@ def curl_content(url, params=None, ajax=False): def link_exist_in_db(href): if MYSQL_ENABLED: - from models import AnimeLink + from pynyaata.models import AnimeLink return AnimeLink.query.filter_by(link=href).first() return False diff --git a/forms.py b/pynyaata/forms.py similarity index 100% rename from forms.py rename to pynyaata/forms.py diff --git a/get404.py b/pynyaata/get404.py similarity index 76% rename from get404.py rename to pynyaata/get404.py index 56d23e5..c4c07b2 100644 --- a/get404.py +++ b/pynyaata/get404.py @@ -1,6 +1,6 @@ -from config import app -from connectors import curl_content -from models import AnimeLink +from pynyaata.config import app +from pynyaata.connectors import curl_content +from pynyaata.models import AnimeLink app.config['SQLALCHEMY_ECHO'] = False links = AnimeLink.query.all() diff --git a/models.py b/pynyaata/models.py similarity index 97% rename from models.py rename to pynyaata/models.py index 6ea14ea..3b259a4 100644 --- a/models.py +++ b/pynyaata/models.py @@ -1,4 +1,4 @@ -from config import db +from pynyaata.config import db class AnimeFolder(db.Model): diff --git a/static/css/bulma-tooltip.min.css b/pynyaata/static/css/bulma-tooltip.min.css similarity index 100% rename from static/css/bulma-tooltip.min.css rename to pynyaata/static/css/bulma-tooltip.min.css diff --git a/static/css/bulma.css.map b/pynyaata/static/css/bulma.css.map similarity index 100% rename from static/css/bulma.css.map rename to pynyaata/static/css/bulma.css.map diff --git a/static/css/bulma.min.css b/pynyaata/static/css/bulma.min.css similarity index 100% rename from static/css/bulma.min.css rename to pynyaata/static/css/bulma.min.css diff --git a/static/css/font-awesome.css.map b/pynyaata/static/css/font-awesome.css.map similarity index 100% rename from static/css/font-awesome.css.map rename to pynyaata/static/css/font-awesome.css.map diff --git a/static/css/font-awesome.min.css b/pynyaata/static/css/font-awesome.min.css similarity index 100% rename from static/css/font-awesome.min.css rename to pynyaata/static/css/font-awesome.min.css diff --git a/static/css/styles.css b/pynyaata/static/css/styles.css similarity index 100% rename from static/css/styles.css rename to pynyaata/static/css/styles.css diff --git a/static/favicons/animeultime.png b/pynyaata/static/favicons/animeultime.png similarity index 100% rename from static/favicons/animeultime.png rename to pynyaata/static/favicons/animeultime.png diff --git a/static/favicons/blank.png b/pynyaata/static/favicons/blank.png similarity index 100% rename from static/favicons/blank.png rename to pynyaata/static/favicons/blank.png diff --git a/static/favicons/favicon.ico b/pynyaata/static/favicons/favicon.ico similarity index 100% rename from static/favicons/favicon.ico rename to pynyaata/static/favicons/favicon.ico diff --git a/static/favicons/nyaa.png b/pynyaata/static/favicons/nyaa.png similarity index 100% rename from static/favicons/nyaa.png rename to pynyaata/static/favicons/nyaa.png diff --git a/static/favicons/pantsu.png b/pynyaata/static/favicons/pantsu.png similarity index 100% rename from static/favicons/pantsu.png rename to pynyaata/static/favicons/pantsu.png diff --git a/static/favicons/yggtorrent.png b/pynyaata/static/favicons/yggtorrent.png similarity index 100% rename from static/favicons/yggtorrent.png rename to pynyaata/static/favicons/yggtorrent.png diff --git a/static/fonts/FontAwesome.otf b/pynyaata/static/fonts/FontAwesome.otf similarity index 100% rename from static/fonts/FontAwesome.otf rename to pynyaata/static/fonts/FontAwesome.otf diff --git a/static/fonts/fontawesome-webfont.eot b/pynyaata/static/fonts/fontawesome-webfont.eot similarity index 100% rename from static/fonts/fontawesome-webfont.eot rename to pynyaata/static/fonts/fontawesome-webfont.eot diff --git a/static/fonts/fontawesome-webfont.svg b/pynyaata/static/fonts/fontawesome-webfont.svg similarity index 100% rename from static/fonts/fontawesome-webfont.svg rename to pynyaata/static/fonts/fontawesome-webfont.svg diff --git a/static/fonts/fontawesome-webfont.ttf b/pynyaata/static/fonts/fontawesome-webfont.ttf similarity index 100% rename from static/fonts/fontawesome-webfont.ttf rename to pynyaata/static/fonts/fontawesome-webfont.ttf diff --git a/static/fonts/fontawesome-webfont.woff b/pynyaata/static/fonts/fontawesome-webfont.woff similarity index 100% rename from static/fonts/fontawesome-webfont.woff rename to pynyaata/static/fonts/fontawesome-webfont.woff diff --git a/static/fonts/fontawesome-webfont.woff2 b/pynyaata/static/fonts/fontawesome-webfont.woff2 similarity index 100% rename from static/fonts/fontawesome-webfont.woff2 rename to pynyaata/static/fonts/fontawesome-webfont.woff2 diff --git a/templates/admin/edit.html b/pynyaata/templates/admin/edit.html similarity index 100% rename from templates/admin/edit.html rename to pynyaata/templates/admin/edit.html diff --git a/templates/admin/list.html b/pynyaata/templates/admin/list.html similarity index 100% rename from templates/admin/list.html rename to pynyaata/templates/admin/list.html diff --git a/templates/latest.html b/pynyaata/templates/latest.html similarity index 100% rename from templates/latest.html rename to pynyaata/templates/latest.html diff --git a/templates/layout.html b/pynyaata/templates/layout.html similarity index 100% rename from templates/layout.html rename to pynyaata/templates/layout.html diff --git a/templates/list.html b/pynyaata/templates/list.html similarity index 100% rename from templates/list.html rename to pynyaata/templates/list.html diff --git a/templates/search.html b/pynyaata/templates/search.html similarity index 100% rename from templates/search.html rename to pynyaata/templates/search.html diff --git a/run.py b/run.py new file mode 100644 index 0000000..67a5ab9 --- /dev/null +++ b/run.py @@ -0,0 +1,12 @@ +from logging import getLogger +from time import sleep + +from pynyaata.config import app, APP_PORT, IS_DEBUG + +while True: + try: + app.run('0.0.0.0', APP_PORT, IS_DEBUG) + except Exception as e: + getLogger().exception(e) + sleep(10) + pass