-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
♻️ #1 Now could able to call socketio events even in other file
- Loading branch information
1 parent
f332473
commit 6ba3d99
Showing
2 changed files
with
22 additions
and
7 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,32 @@ | ||
from flask import Flask | ||
from flask_socketio import SocketIO | ||
|
||
# from .middleware.communication import get_cam_feed | ||
|
||
socketio: SocketIO = SocketIO | ||
|
||
|
||
def create_app(): | ||
app = Flask(__name__, template_folder='templates') | ||
app.config['SECRET_KEY'] = 'secret!' | ||
socketio = SocketIO(app, cors_allowed_origins="*")#, logger=True, engineio_logger=True) # to run websockets for this flask app. A new server runs for this. | ||
|
||
|
||
""" ----------- Register blueprints -----------""" | ||
from .web import web as main_blueprint # for displaying web-pages | ||
# from .feed import feed # for handling camera and ultra-sonic feed | ||
|
||
app.register_blueprint(main_blueprint, url_prefix='/') | ||
# app.register_blueprint(feed, url_prefix='/feed') | ||
|
||
|
||
return socketio, app | ||
global socketio | ||
# , logger=True, engineio_logger=True) # to run websockets for this flask app. A new server runs for this. | ||
socketio = SocketIO(app, cors_allowed_origins="*") | ||
|
||
return app | ||
|
||
|
||
# Create the application.. | ||
socketio, app = create_app() | ||
app = create_app() | ||
print("Application created") | ||
|
||
# Get the event handlers | ||
from .middleware.communication.web_communicator import handle_connect, handle_stream, handle_disconnect | ||
from .middleware.communication import get_cam_feed |
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