user handling done
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2020-11-24 20:26:02 +01:00
parent f54d752657
commit e02bf1aa62
9 changed files with 207 additions and 7 deletions

View File

@@ -9,8 +9,11 @@ from healthcheck import HealthCheck
from config import *
from db import db
from jwtman import jwtman
from fbcrypt import bcrypt
from marshm import ma
from healthchecks import health_database_status
from resources import SignupApi, LoginApi
"""
Main Flask RESTful API
@@ -35,15 +38,19 @@ if SENTRY_DSN:
app = Flask(__name__)
app.config['SQLALCHEMY_DATABASE_URI'] =\
f"postgresql://{POSTGRES_USERNAME}:{POSTGRES_PASSWORD}@{POSTGRES_HOSTNAME}:5432/{POSTGRES_DB}"
app.config['JWT_SECRET_KEY'] = JWT_SECRET_KEY
app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False
api = Api(app)
health = HealthCheck(app, "/healthz")
db.init_app(app)
ma.init_app(app)
bcrypt.init_app(app)
jwtman.init_app(app)
with app.app_context():
db.create_all()
""
formatter = logging.Formatter(
fmt="%(asctime)s - %(levelname)s - %(module)s - %(message)s"
)
@@ -56,9 +63,17 @@ logger.setLevel(logging.DEBUG)
logger.addHandler(handler)
# api.add_resource(SampleResource, "/sample")
api.add_resource(SignupApi, '/api/auth/signup')
api.add_resource(LoginApi, '/api/auth/login')
health.add_check(health_database_status)
@app.errorhandler(404)
def page_not_found(e):
return {'status': 'error', 'message': 'page not found'}, 404
if __name__ == "__main__":
app.run(
debug=bool(DEBUG),