-
-
Save Kd-Here/0b6e8a6fcc7c44a702882ba738031c84 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'] = 'fdadjfaoef afdpp' | |
app.config['SQLALCHEMY_DATABASE_URI'] = f'sqlite:///{DB_NAME}' #This stores sqlite database in current dir | |
db.init_app(app) #This show what is app our database is storing | |
from .views import views | |
from .auth import auth | |
app.register_blueprint(views,url_prefix='/') | |
# app.register_blueprint(auth,url_prefix='/auth/') #What's different between both this here before every url it must /auth/ then what you want | |
app.register_blueprint(auth,url_prefix='/') #It will be / only no prefix-> before url | |
from .models import User,Note | |
create_database() | |
return app | |
def create_database(): | |
if not path.exists('website/'+DB_NAME): | |
print("Created Database!") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment