-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfactory.py
More file actions
39 lines (29 loc) · 1.18 KB
/
factory.py
File metadata and controls
39 lines (29 loc) · 1.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
"""
factory.py - Chatbot App Factory
This file contains the factory function for creating the Chatbot app. The factory function creates a Flask app with the chatbot registered with it. It also configures the Flask app. The factory function is used in the 'app.py' file to create the Chatbot app.
Author: Wes Modes
Date: 2023
"""
import flask
from chatbot import Chatbot
from routes import routes
import config
import logging
# Configure the logger for the 'routes' module
routes_logger = logging.getLogger('httpd_logger')
# log_format = '%(asctime)s - %(name)s - %(levelname)s - %(message)s'
routes_log_handler = logging.FileHandler(config.ACCESS_LOG)
# routes_log_handler.setFormatter(logging.Formatter(log_format))
routes_logger.addHandler(routes_log_handler)
routes_logger.setLevel(logging.INFO)
# Create a logger for the 'chatbot' module, writing to stdout
chatbot_logger = logging.getLogger('chatbot_logger')
chatbot_logger.setLevel(logging.INFO)
def create_app():
app = flask.Flask(__name__)
# Create a chatbot instance
chatbot = Chatbot()
# Register the chatbot blueprint with the Flask app
app.register_blueprint(routes(chatbot))
# Configure the Flask app
return app