TG-103 Amélioration structure du projet
This commit is contained in:
@ -15,4 +15,4 @@ class SomeApi(Resource):
|
||||
return {'somedelete': 'somedeletedata'}, 204
|
||||
|
||||
def put(self, id=None):
|
||||
return {'someput': 'someputdata'}, 204
|
||||
return {'someput': 'someputdata'}, 201
|
||||
|
@ -2,6 +2,19 @@ import os
|
||||
|
||||
|
||||
class Config:
|
||||
ACTIVE_CONFIG = "app.config.Prod"
|
||||
|
||||
@staticmethod
|
||||
def configure_app(config="prod"):
|
||||
if config.lower() == "prod":
|
||||
Config.ACTIVE_CONFIG = 'app.config.Prod'
|
||||
elif config.lower() == "debug":
|
||||
Config.ACTIVE_CONFIG = 'app.config.Debug'
|
||||
elif config.lower() == "test":
|
||||
Config.ACTIVE_CONFIG = 'app.config.Test'
|
||||
else:
|
||||
raise Exception('{} n\'est pas configuration une configuration valide'.format(config))
|
||||
|
||||
DEBUG = False
|
||||
TESTING = False
|
||||
BASE_DIR = os.path.abspath(os.path.dirname(__file__))
|
@ -6,30 +6,21 @@ from flask_restful import Api
|
||||
from flask_sqlalchemy import SQLAlchemy
|
||||
from sqlalchemy import create_engine
|
||||
from sqlalchemy.ext.automap import automap_base
|
||||
|
||||
|
||||
def configure_app(config="prod"):
|
||||
if config.lower() == "debug":
|
||||
app.config.from_object('app.config.Debug')
|
||||
elif config.lower() == "test":
|
||||
app.config.from_object('app.config.Test')
|
||||
else:
|
||||
app.config.from_object('app.config.Prod')
|
||||
|
||||
app.permanent_session_lifetime = \
|
||||
timedelta(
|
||||
minutes=app.config
|
||||
['SESSION_VALIDITY_DURATION_WITHOUT_ACTIVITY_MIN']
|
||||
)
|
||||
|
||||
@app.before_request
|
||||
def before_request():
|
||||
session.modified = True
|
||||
from app.config import Config
|
||||
|
||||
|
||||
# initialization Flask
|
||||
app = Flask(__name__)
|
||||
configure_app()
|
||||
app.config.from_object(Config.ACTIVE_CONFIG)
|
||||
|
||||
app.permanent_session_lifetime = \
|
||||
timedelta(
|
||||
minutes=app.config['SESSION_VALIDITY_DURATION_WITHOUT_ACTIVITY_MIN']
|
||||
)
|
||||
|
||||
@app.before_request
|
||||
def before_request():
|
||||
session.modified = True
|
||||
|
||||
# SQLAlchemy
|
||||
db = SQLAlchemy(app)
|
||||
|
@ -1,4 +1,4 @@
|
||||
from backend.app.core import Base
|
||||
from app.core import Base
|
||||
|
||||
USER = Base.classes.user
|
||||
SETTINGS = Base.classes.settings
|
||||
|
@ -1,4 +1,5 @@
|
||||
from app.core import api
|
||||
from app.api.exampleapi import SomeApi
|
||||
|
||||
# Some Api resource
|
||||
api.add_resource(api, '/api/someapi', '/api/someapi/<int:id>')
|
||||
api.add_resource(SomeApi, '/api/someapi', '/api/someapi/<int:id>')
|
||||
|
Reference in New Issue
Block a user