Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
2
22_23-J-72
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
22_23-J-72
22_23-J-72
Commits
025dc7ca
Commit
025dc7ca
authored
May 28, 2023
by
IT19953748_D D P Kumara
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
file
parent
57373857
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
45 additions
and
0 deletions
+45
-0
website/__init__.py
website/__init__.py
+45
-0
No files found.
website/__init__.py
0 → 100644
View file @
025dc7ca
from
flask
import
Flask
from
flask_sqlalchemy
import
SQLAlchemy
from
os
import
path
from
flask_login
import
LoginManager
db
=
SQLAlchemy
()
DB_NAME
=
"database.db"
def
create_app
():
app
=
Flask
(
__name__
)
app
.
config
[
'SECRET_KEY'
]
=
'hjshjhdjah kjshkjdhjs'
app
.
config
[
'SQLALCHEMY_DATABASE_URI'
]
=
f
'sqlite:///{DB_NAME}'
db
.
init_app
(
app
)
from
.views
import
views
from
.auth
import
auth
app
.
register_blueprint
(
views
,
url_prefix
=
'/'
)
app
.
register_blueprint
(
auth
,
url_prefix
=
'/'
)
from
.models
import
User
,
Note
with
app
.
app_context
():
db
.
create_all
()
login_manager
=
LoginManager
()
login_manager
.
login_view
=
'auth.login'
login_manager
.
init_app
(
app
)
@
login_manager
.
user_loader
def
load_user
(
id
):
return
User
.
query
.
get
(
int
(
id
))
return
app
def
create_database
(
app
):
if
not
path
.
exists
(
'website/'
+
DB_NAME
):
db
.
create_all
(
app
=
app
)
print
(
'Created Database!'
)
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment