Код: Выделить всё
from flask import Flask
from flask_sqlalchemy import SQLAlchemy
from os import path
db = SQLAlchemy()
DB_NAME = "database.db"
def create_app():
app = Flask(__name__)
app.config['SECRET_KEY'] = 'meow'
app.config['SQLALCHEMY_DATABASE_URI'] = f'sqlite:///{DB_NAME}'
db.init_app(app)
from .views import views
from .authorisation import authorisation
app.register_blueprint(views, url_prefix='/')
app.register_blueprint(authorisation, url_prefix='/')
from .models import Student, Teacher, Grade
create_database(app)
return app
def create_database(app):
if not path.exists('website/' + DB_NAME):
db.create_all(app = app)
print('Create database.')
Подробнее здесь: https://stackoverflow.com/questions/794 ... ent-app-wh
Мобильная версия