This commit is contained in:
parent
f192459855
commit
9c046b63d9
14
Dockerfile
14
Dockerfile
@ -1,9 +1,13 @@
|
|||||||
FROM python:3
|
FROM python:3.8-slim
|
||||||
|
|
||||||
WORKDIR /app
|
ADD consumer_api requirements.txt /consumer_api/
|
||||||
|
WORKDIR /consumer_api/
|
||||||
|
|
||||||
COPY . ./
|
ENV PIP_NO_CACHE_DIR=true
|
||||||
|
ENV TZ Europe/Budapest
|
||||||
|
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
|
||||||
|
|
||||||
RUN pip3 install --no-cache-dir -r requirements.txt
|
RUN pip3 install -r requirements.txt
|
||||||
|
|
||||||
CMD ["python3", "app.py"]
|
EXPOSE 8000
|
||||||
|
CMD ["gunicorn", "-b", "0.0.0.0:8000", "app:app"]
|
||||||
|
16
app.py
16
app.py
@ -1,16 +0,0 @@
|
|||||||
#!/usr/bin/env python
|
|
||||||
import sentry_sdk
|
|
||||||
|
|
||||||
"""
|
|
||||||
Main Flask RESTful API
|
|
||||||
"""
|
|
||||||
|
|
||||||
__author__ = "@tormakris"
|
|
||||||
__copyright__ = "Copyright 2020, GoldenPogácsa Team"
|
|
||||||
__module_name__ = "app"
|
|
||||||
__version__text__ = "1"
|
|
||||||
|
|
||||||
sentry_sdk.init("https://0a106e104e114bc9a3fa47f9cb0db2f4@sentry.kmlabz.com/10")
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
|
||||||
print("Producer")
|
|
28
consumer_api/app.py
Normal file
28
consumer_api/app.py
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
import sentry_sdk
|
||||||
|
from flask import Flask
|
||||||
|
import os
|
||||||
|
from db import redis_client
|
||||||
|
from views import ConsumersView, LogView, SyncView
|
||||||
|
|
||||||
|
"""
|
||||||
|
Main Flask RESTful API
|
||||||
|
"""
|
||||||
|
|
||||||
|
__author__ = "@tormakris"
|
||||||
|
__copyright__ = "Copyright 2020, GoldenPogácsa Team"
|
||||||
|
__module_name__ = "app"
|
||||||
|
__version__text__ = "1"
|
||||||
|
|
||||||
|
sentry_sdk.init("https://0a106e104e114bc9a3fa47f9cb0db2f4@sentry.kmlabz.com/10")
|
||||||
|
|
||||||
|
app = Flask(__name__)
|
||||||
|
app.config['REDIS_URL'] = os.environ['REDIS_URL']
|
||||||
|
|
||||||
|
redis_client.init_app(app)
|
||||||
|
|
||||||
|
for view in [ConsumersView, LogView, SyncView]:
|
||||||
|
view.register(app, trailing_slash=False)
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
app.run(debug=True)
|
3
consumer_api/db.py
Normal file
3
consumer_api/db.py
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
from flask_redis import FlaskRedis
|
||||||
|
|
||||||
|
redis_client = FlaskRedis()
|
3
consumer_api/views/__init__.py
Normal file
3
consumer_api/views/__init__.py
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
from .consumers_view import ConsumersView
|
||||||
|
from .log_view import LogView
|
||||||
|
from .sync_view import SyncView
|
7
consumer_api/views/consumers_view.py
Normal file
7
consumer_api/views/consumers_view.py
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
from flask_classful import FlaskView
|
||||||
|
|
||||||
|
|
||||||
|
class ConsumersView(FlaskView):
|
||||||
|
|
||||||
|
def get(self):
|
||||||
|
return "ConsumersView"
|
7
consumer_api/views/log_view.py
Normal file
7
consumer_api/views/log_view.py
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
from flask_classful import FlaskView
|
||||||
|
|
||||||
|
|
||||||
|
class LogView(FlaskView):
|
||||||
|
|
||||||
|
def get(self):
|
||||||
|
return "LogView"
|
7
consumer_api/views/sync_view.py
Normal file
7
consumer_api/views/sync_view.py
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
from flask_classful import FlaskView
|
||||||
|
|
||||||
|
|
||||||
|
class SyncView(FlaskView):
|
||||||
|
|
||||||
|
def get(self):
|
||||||
|
return "SyncView"
|
@ -1,3 +1,5 @@
|
|||||||
sentry_sdk
|
sentry_sdk
|
||||||
flask
|
flask
|
||||||
flask-redis
|
flask-redis
|
||||||
|
flask-classful
|
||||||
|
gunicorn
|
Reference in New Issue
Block a user