Skip to content

Commit

Permalink
refactor: create flask app using function
Browse files Browse the repository at this point in the history
  • Loading branch information
nhymxu committed May 7, 2024
1 parent 13df12e commit 2bfb1e0
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 6 deletions.
13 changes: 13 additions & 0 deletions logics/webserver.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import os

from flask import Flask

from logics.error_handler import ErrorHandler


def create_app():
app = Flask(__name__)
app.config['SERVER_AUTH_KEY'] = os.getenv('SERVER_AUTH_KEY')
ErrorHandler(app)

return app
10 changes: 4 additions & 6 deletions web.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,17 @@
import base64
import io
import os

from asgiref.wsgi import WsgiToAsgi
from dotenv import load_dotenv
from flask import Flask, send_file
from flask import send_file

from logics.auth_middleware import require_authentication
from logics.error_handler import ErrorHandler

from logics.webserver import create_app


load_dotenv()
app = Flask(__name__)
app.config['SERVER_AUTH_KEY'] = os.getenv('SERVER_AUTH_KEY')
ErrorHandler(app)
app = create_app()

asgi_app = WsgiToAsgi(app)

Expand Down

0 comments on commit 2bfb1e0

Please sign in to comment.