Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
W
webomagic-auth
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Pratik Shrivastava
webomagic-auth
Commits
4b5f0f87
Commit
4b5f0f87
authored
Jul 15, 2024
by
deepdey
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
build: implement flask applicator factory
parent
c5600d35
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
16 deletions
+18
-16
app/__init__.py
app/__init__.py
+16
-15
main.py
main.py
+2
-1
No files found.
app/__init__.py
View file @
4b5f0f87
...
...
@@ -4,26 +4,27 @@ from flask_bcrypt import Bcrypt
from
flask_sqlalchemy
import
SQLAlchemy
from
app.app_config.config
import
DB_URI
db
:
SQLAlchemy
=
SQLAlchemy
()
bcrypt
:
Bcrypt
=
Bcrypt
()
def
create_app
():
# instantiating required classes
app
:
Flask
=
Flask
(
__name__
)
# instantiating required classes
app
:
Flask
=
Flask
(
__name__
)
cors
:
CORS
=
CORS
(
app
,
resources
=
{
r'/*'
:
{
'origins'
:
'*'
}})
cors
:
CORS
=
CORS
(
app
,
resources
=
{
r'/*'
:
{
'origins'
:
'*'
}})
# db configuration
app
.
config
[
'SQLALCHEMY_DATABASE_URI'
]
=
DB_URI
app
.
config
[
'SQLALCHEMY_TRACK_MODIFICATIONS'
]
=
False
# db configuration
app
.
config
[
'SQLALCHEMY_DATABASE_URI'
]
=
DB_URI
app
.
config
[
'SQLALCHEMY_TRACK_MODIFICATIONS'
]
=
False
db
.
init_app
(
app
)
bcrypt
.
init_app
(
app
)
db
:
SQLAlchemy
=
SQLAlchemy
(
app
)
from
app
import
routes
# IMPORTANT: BCRYPT IS USED FOR HASHING THE PASSWORD ONLY AS IT IS CPU INTENSIVE
bcrypt
=
Bcrypt
(
app
)
# registering routes for each sub-folder in routes
app
.
register_blueprint
(
routes
.
blueprint
)
app
.
config
[
'RESTX_MASK_SWAGGER'
]
=
False
from
app
import
routes
# registering routes for each sub-folder in routes
app
.
register_blueprint
(
routes
.
blueprint
)
app
.
config
[
'RESTX_MASK_SWAGGER'
]
=
False
return
app
main.py
View file @
4b5f0f87
from
app
import
app
from
app
import
create_
app
from
app.app_config.config
import
SERVER_HOST
,
SERVER_PORT
,
get_logger
logger
=
get_logger
(
__name__
)
if
__name__
==
'__main__'
:
app
=
create_app
()
app
.
run
(
host
=
SERVER_HOST
,
debug
=
True
,
port
=
SERVER_PORT
)
\ 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