diff --git a/Dockerfile b/Dockerfile index d682e7f..7e238a9 100644 --- a/Dockerfile +++ b/Dockerfile @@ -9,4 +9,4 @@ RUN bash setup_core.sh RUN pip3 install -r requirements.txt EXPOSE 5000/udp EXPOSE 5000/tcp -CMD ["python3", "ayct-backend/app.py"] \ No newline at end of file +CMD ["python3 -m", "ayct-backend.app"] \ No newline at end of file diff --git a/ayct-backend/__init__.py b/ayct-backend/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/ayct-backend/app.py b/ayct-backend/app.py deleted file mode 100644 index 2700cf0..0000000 --- a/ayct-backend/app.py +++ /dev/null @@ -1,20 +0,0 @@ -from flask import Flask -from flask_restful import Api, Resource -import os -import pbrAyctCore.core as core - -app = Flask(__name__) -api = Api(app) - -class Hello(Resource): - def get(self): - return core.getTestString() - -api.add_resource(Hello, "/hello") - -def create_app(): - return app - -if __name__ == "__main__": - port = int(os.environ.get('PORT', 5000)) - app.run(host = '0.0.0.0', port = port) diff --git a/ayct_backend/__init__.py b/ayct_backend/__init__.py new file mode 100644 index 0000000..6c67c1c --- /dev/null +++ b/ayct_backend/__init__.py @@ -0,0 +1,11 @@ +from flask import Flask +import pbrAyctCore.core as core + +def create_app(): + app = Flask('ayct-backend') + + @app.route('/hello') + def hello(): + return core.getTestString() + + return app \ No newline at end of file diff --git a/ayct_backend/app.py b/ayct_backend/app.py new file mode 100644 index 0000000..33883c6 --- /dev/null +++ b/ayct_backend/app.py @@ -0,0 +1,7 @@ +import os +from . import create_app + +if __name__ == "__main__": + app = create_app() + port = int(os.environ.get('PORT', 5000)) + app.run(host = '0.0.0.0', port = port) diff --git a/pyproject.toml b/pyproject.toml deleted file mode 100644 index 15f7d66..0000000 --- a/pyproject.toml +++ /dev/null @@ -1,7 +0,0 @@ -[build-system] -requires = [ - "setuptools>=42", - "wheel", - "flask" -] -build-backend = "setuptools.build_meta" \ No newline at end of file diff --git a/setup.cfg b/setup.cfg index d157efd..8412a47 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,24 +1,5 @@ -[metadata] -name = pbrAyctBackend -version = 0.0.1 -author = Łukasz Ramon Piotrek -author_email = ramon.dyzman@gmail.com -description = A small example package -long_description = file: readme.md -long_description_content_type = text/markdown -url = https://git.wmi.amu.edu.pl/s434708/pbr-ayct-backend -project_urls = - Bug Tracker = https://github.com/pypa/sampleproject/issues -classifiers = - Programming Language :: Python :: 3 - License :: OSI Approved :: MIT License - Operating System :: OS Independent +[bdist_wheel] +universal = True -[options] -package_dir = - = ayct-backend -packages = find: -python_requires = >=3.6 - -[options.packages.find] -where = src \ No newline at end of file +[tool:pytest] +testpaths = tests diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..bbd0ca4 --- /dev/null +++ b/setup.py @@ -0,0 +1,20 @@ +import io + +from setuptools import find_packages +from setuptools import setup + + +setup( + name="ayct_backend", + version="1.0.0", + url="https://git.wmi.amu.edu.pl/s434708/pbr-ayct-backend", + license="BSD", + maintainer="RŁP", + maintainer_email="random@mail.com", + description="Backend for AYCT", + packages=find_packages(), + include_package_data=True, + zip_safe=False, + install_requires=["flask"], + extras_require={"test": ["pytest"]}, +) \ No newline at end of file diff --git a/ayct-backend/tests/test_ayct_backend.py b/tests/test_ayct_backend.py similarity index 73% rename from ayct-backend/tests/test_ayct_backend.py rename to tests/test_ayct_backend.py index 96528a1..753ad7d 100644 --- a/ayct-backend/tests/test_ayct_backend.py +++ b/tests/test_ayct_backend.py @@ -2,12 +2,12 @@ import os import tempfile import pytest - -from app import create_app +from ayct_backend import create_app @pytest.fixture def client(): app = create_app() + app.config['TESTING'] = True app.run(host = '0.0.0.0', port = 5000) with app.test_client() as client: