init
parent
0475a145f4
commit
52459a009c
@ -1,28 +0,0 @@
|
||||
import os
|
||||
|
||||
from flask import Blueprint, jsonify, request
|
||||
|
||||
from project.api.models import User
|
||||
|
||||
|
||||
users_blueprint = Blueprint('users', __name__, template_folder='./templates')
|
||||
|
||||
|
||||
@users_blueprint.route('/users/ping', methods=['GET'])
|
||||
def ping_pong():
|
||||
return jsonify({
|
||||
'status': 'success',
|
||||
'message': 'pong!',
|
||||
'container_id': os.uname()[1]
|
||||
})
|
||||
|
||||
|
||||
@users_blueprint.route('/users', methods=['GET'])
|
||||
def get_all_users():
|
||||
"""Get all users"""
|
||||
response_object = {
|
||||
'status': 'success',
|
||||
'users': [user.to_json() for user in User.query.all()],
|
||||
'container_id': os.uname()[1]
|
||||
}
|
||||
return jsonify(response_object), 200
|
@ -1,7 +0,0 @@
|
||||
import os
|
||||
|
||||
|
||||
class DevelopmentConfig():
|
||||
"""Development configuration"""
|
||||
SQLALCHEMY_TRACK_MODIFICATIONS = False
|
||||
SQLALCHEMY_DATABASE_URI = os.environ.get('DATABASE_URL')
|
@ -0,0 +1,4 @@
|
||||
FROM nginx:1.15.0-alpine
|
||||
|
||||
RUN rm /etc/nginx/conf.d/default.conf
|
||||
COPY /prod.conf /etc/nginx/conf.d
|
@ -0,0 +1,14 @@
|
||||
server {
|
||||
|
||||
listen 80;
|
||||
|
||||
location / {
|
||||
proxy_pass http://web:5000;
|
||||
proxy_redirect default;
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header X-Forwarded-Host $server_name;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,33 @@
|
||||
import os
|
||||
import logging
|
||||
|
||||
from flask import Blueprint, jsonify, request
|
||||
|
||||
|
||||
LOGGER = logging.getLogger('gunicorn.error')
|
||||
SECRET_CODE = os.environ.get('SECRET_CODE')
|
||||
|
||||
main_blueprint = Blueprint('main', __name__)
|
||||
|
||||
|
||||
@main_blueprint.route('/ping', methods=['GET'])
|
||||
def ping_pong():
|
||||
LOGGER.info('Hitting the "/ping" route')
|
||||
return jsonify({
|
||||
'status': 'success',
|
||||
'message': 'pong!',
|
||||
'container_id': os.uname()[1]
|
||||
})
|
||||
|
||||
|
||||
@main_blueprint.route('/secret', methods=['POST'])
|
||||
def secret():
|
||||
LOGGER.info('Hitting the "/secret" route')
|
||||
response_object = {
|
||||
'status': 'success',
|
||||
'message': 'nay!',
|
||||
'container_id': os.uname()[1]
|
||||
}
|
||||
if request.get_json().get('secret') == SECRET_CODE:
|
||||
response_object['message'] = 'yay!'
|
||||
return jsonify(response_object)
|
@ -1,5 +1,3 @@
|
||||
from flask import current_app
|
||||
|
||||
from project import db
|
||||
|
||||
|
@ -0,0 +1,22 @@
|
||||
import os
|
||||
import logging
|
||||
|
||||
from flask import Blueprint, jsonify
|
||||
|
||||
from project.api.models import User
|
||||
|
||||
|
||||
users_blueprint = Blueprint('users', __name__)
|
||||
|
||||
LOGGER = logging.getLogger('gunicorn.error')
|
||||
|
||||
|
||||
@users_blueprint.route('/users', methods=['GET'])
|
||||
def get_all_users():
|
||||
LOGGER.info('Hitting the "/users" route')
|
||||
response_object = {
|
||||
'status': 'success',
|
||||
'users': [user.to_json() for user in User.query.all()],
|
||||
'container_id': os.uname()[1]
|
||||
}
|
||||
return jsonify(response_object), 200
|
@ -0,0 +1,10 @@
|
||||
import os
|
||||
|
||||
USER = os.environ.get('DB_USER')
|
||||
PASSWORD = os.environ.get('DB_PASSWORD')
|
||||
|
||||
|
||||
class ProductionConfig():
|
||||
"""Production configuration"""
|
||||
SQLALCHEMY_TRACK_MODIFICATIONS = False
|
||||
SQLALCHEMY_DATABASE_URI = f'postgres://{USER}:{PASSWORD}@db:5432/users'
|
Loading…
Reference in New Issue