This commit is contained in:
wangobango 2021-12-01 14:25:42 +01:00
parent 1dc93c5f0d
commit 1f6260c976
9 changed files with 45 additions and 53 deletions

View File

@ -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"]
CMD ["python3 -m", "ayct-backend.app"]

View File

@ -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)

11
ayct_backend/__init__.py Normal file
View File

@ -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

7
ayct_backend/app.py Normal file
View File

@ -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)

View File

@ -1,7 +0,0 @@
[build-system]
requires = [
"setuptools>=42",
"wheel",
"flask"
]
build-backend = "setuptools.build_meta"

View File

@ -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
[tool:pytest]
testpaths = tests

20
setup.py Normal file
View File

@ -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"]},
)

View File

@ -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: