refactor: adds new entry point and ORM
This commit is contained in:
11
app.py
11
app.py
@@ -1,11 +0,0 @@
|
|||||||
from flask_sqlalchemy import SQLAlchemy
|
|
||||||
from flask import Flask, render_template
|
|
||||||
|
|
||||||
db = SQLAlchemy()
|
|
||||||
app = Flask(__name__)
|
|
||||||
app.config["SQLALCHEMY_DATABASE_URI"] = "sqlite:///adogapet.db"
|
|
||||||
db.init_app(app)
|
|
||||||
|
|
||||||
@app.route("/")
|
|
||||||
def hello_world():
|
|
||||||
return render_template("index.html")
|
|
||||||
16
app/__init__.py
Normal file
16
app/__init__.py
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
from flask import Flask
|
||||||
|
|
||||||
|
from config import Config
|
||||||
|
from app.extensions import db
|
||||||
|
|
||||||
|
def create_app(config_class=Config):
|
||||||
|
app = Flask(__name__)
|
||||||
|
app.config.from_object(config_class)
|
||||||
|
db.init_app(app)
|
||||||
|
# Initialize Flask extensions here
|
||||||
|
|
||||||
|
# Register blueprints here
|
||||||
|
from app.main import bp as main_bp
|
||||||
|
app.register_blueprint(main_bp)
|
||||||
|
|
||||||
|
return app
|
||||||
2
app/extensions.py
Normal file
2
app/extensions.py
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
from flask_sqlalchemy import SQLAlchemy
|
||||||
|
db = SQLAlchemy()
|
||||||
10
config.py
Normal file
10
config.py
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
import os
|
||||||
|
|
||||||
|
basedir = os.path.abspath(os.path.dirname(__file__))
|
||||||
|
|
||||||
|
|
||||||
|
class Config:
|
||||||
|
SECRET_KEY = os.environ.get('SECRET_KEY')
|
||||||
|
SQLALCHEMY_DATABASE_URI = os.environ.get('DATABASE_URI')\
|
||||||
|
or 'sqlite:///' + os.path.join(basedir, 'instance\\adogapet.db')
|
||||||
|
SQLALCHEMY_TRACK_MODIFICATIONS = False
|
||||||
Reference in New Issue
Block a user