Update: revert
This commit is contained in:
parent
a5f8ba7a84
commit
66fe84e3eb
7 changed files with 45 additions and 39 deletions
|
|
@ -1,34 +1,8 @@
|
|||
from flask import Flask
|
||||
from flask_sqlalchemy import SQLAlchemy
|
||||
from ddtrace import patch_all
|
||||
import sys
|
||||
from application import create_app
|
||||
import os
|
||||
|
||||
db = SQLAlchemy()
|
||||
patch_all()
|
||||
|
||||
app = create_app()
|
||||
|
||||
if __name__ == "__main__":
|
||||
app = Flask(__name__)
|
||||
FLASK_ENV = os.environ.get('FLASK_ENV', None)
|
||||
if FLASK_ENV == 'production':
|
||||
app.config.from_object("config.ProductionConfig")
|
||||
elif FLASK_ENV == 'staging':
|
||||
app.config.from_object("config.StagingConfig")
|
||||
elif FLASK_ENV == 'development':
|
||||
app.config.from_object("config.DevelopmentConfig")
|
||||
else:
|
||||
app.config.from_object("config.Config")
|
||||
|
||||
if app.config['SQLALCHEMY_DATABASE_URI_1'] is None or app.config['SQLALCHEMY_DATABASE_URI_2'] is None:
|
||||
print('No ENV Variables for DATABASE_URL_1 or DATABASE_URL_2')
|
||||
sys.exit(1)
|
||||
else:
|
||||
print('ENV Variables passed : ', app.config['SQLALCHEMY_BINDS'])
|
||||
|
||||
# db.init_app(app)
|
||||
# with app.app_context():
|
||||
# from . import routes
|
||||
# db.create_all()
|
||||
PORT = os.environ.get('PORT', 4999)
|
||||
PORT = os.environ.get('PORT', 33507)
|
||||
app.run(host='0.0.0.0', port=PORT)
|
||||
|
|
|
|||
33
backend/application/__init__.py
Normal file
33
backend/application/__init__.py
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
from flask import Flask
|
||||
from flask_sqlalchemy import SQLAlchemy
|
||||
from ddtrace import patch_all
|
||||
import sys
|
||||
import os
|
||||
|
||||
db = SQLAlchemy()
|
||||
patch_all()
|
||||
|
||||
|
||||
def create_app():
|
||||
app = Flask(__name__)
|
||||
FLASK_ENV = os.environ.get('FLASK_ENV', None)
|
||||
if FLASK_ENV == 'production':
|
||||
app.config.from_object("config.ProductionConfig")
|
||||
elif FLASK_ENV == 'staging':
|
||||
app.config.from_object("config.StagingConfig")
|
||||
elif FLASK_ENV == 'development':
|
||||
app.config.from_object("config.DevelopmentConfig")
|
||||
else:
|
||||
app.config.from_object("config.Config")
|
||||
|
||||
if app.config['SQLALCHEMY_DATABASE_URI_1'] is None or app.config['SQLALCHEMY_DATABASE_URI_2'] is None:
|
||||
print('No ENV Variable for DATABASE_URL_1 or DATABASE_URL_2')
|
||||
sys.exit(1)
|
||||
else:
|
||||
print('ENV Variables passed : ', app.config['SQLALCHEMY_BINDS'])
|
||||
|
||||
db.init_app(app)
|
||||
with app.app_context():
|
||||
from . import routes
|
||||
db.create_all()
|
||||
return app
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
from app import db
|
||||
from . import db
|
||||
|
||||
|
||||
class Logs(db.Model):
|
||||
|
|
@ -2,7 +2,7 @@ from flask_script import Manager
|
|||
from flask_migrate import Migrate, MigrateCommand
|
||||
|
||||
from flask import current_app as app
|
||||
from . import db
|
||||
from backend import db
|
||||
|
||||
migrate = Migrate(app, db)
|
||||
manager = Manager(app)
|
||||
|
|
@ -1,7 +1,6 @@
|
|||
from flask import current_app as app
|
||||
from flask import request
|
||||
from logs_model import db
|
||||
from users_model import Users, db
|
||||
from .users_model import Users, db
|
||||
from responses import send_message, send_error
|
||||
|
||||
|
||||
|
|
@ -16,10 +15,10 @@ def login():
|
|||
def register():
|
||||
post_email = str(request.form['email'])
|
||||
post_login = str(request.form['login'])
|
||||
post_hashPass = str(request.form['hashPass'])
|
||||
post_hash_pass = str(request.form['hashPass'])
|
||||
post_role = str(request.form['role'])
|
||||
|
||||
if post_email and post_login and post_hashPass and post_role:
|
||||
if post_email and post_login and post_hash_pass and post_role:
|
||||
user = Users.query.filter(
|
||||
Users.email == post_email or Users.login == post_login
|
||||
).first()
|
||||
|
|
@ -28,7 +27,7 @@ def register():
|
|||
user = Users(
|
||||
email=post_email,
|
||||
login=post_login,
|
||||
hashPass=post_hashPass,
|
||||
hashPass=post_hash_pass,
|
||||
role=post_role
|
||||
)
|
||||
db.session.add(user)
|
||||
|
|
@ -58,9 +57,9 @@ def user_delete():
|
|||
|
||||
|
||||
# Admin : Create User
|
||||
@app.route('/api/user/create', methods=['POST'])
|
||||
@app.route('/api/admin/create/user/', methods=['POST'])
|
||||
def user_create():
|
||||
return send_message('User.create not implemented', None)
|
||||
return send_message('Admin.create.user not implemented', None)
|
||||
|
||||
|
||||
# Admin : Change User password
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
from app import db
|
||||
from . import db
|
||||
|
||||
|
||||
class Users(db.Model):
|
||||
Loading…
Add table
Add a link
Reference in a new issue