Created app skeleton
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Pünkösd Marcell 2020-03-29 17:08:53 +02:00
parent f192459855
commit 9c046b63d9
9 changed files with 67 additions and 22 deletions

View File

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

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

@ -0,0 +1,3 @@
from flask_redis import FlaskRedis
redis_client = FlaskRedis()

View File

@ -0,0 +1,3 @@
from .consumers_view import ConsumersView
from .log_view import LogView
from .sync_view import SyncView

View File

@ -0,0 +1,7 @@
from flask_classful import FlaskView
class ConsumersView(FlaskView):
def get(self):
return "ConsumersView"

View File

@ -0,0 +1,7 @@
from flask_classful import FlaskView
class LogView(FlaskView):
def get(self):
return "LogView"

View File

@ -0,0 +1,7 @@
from flask_classful import FlaskView
class SyncView(FlaskView):
def get(self):
return "SyncView"

View File

@ -1,3 +1,5 @@
sentry_sdk
flask
flask-redis
flask-classful
gunicorn