Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom Flask Configurations for AGVis #67

Merged
merged 1 commit into from
Jan 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions agvis/flask_configurations.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# ================================================================================
# File Name: flask_configurations.py
# Author: Zack Malkmus
# Date: 1/18/2024 (created)
# Description: Configuration file for FLASK APP
# ================================================================================

class DefaultConfig(object):
DEBUG = False
TESTING = False
CSRF_ENABLED = True

class ProductionConfig(DefaultConfig):
DEBUG = False

class DevelopmentConfig(DefaultConfig):
DEVELOPMENT = True
DEBUG = True

class TestingConfig(DefaultConfig):
TESTING = True
6 changes: 6 additions & 0 deletions agvis/web.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import sys
import subprocess
from flask import Flask, render_template, send_from_directory
from .flask_configurations import *
import requests

class AgvisWeb():
Expand Down Expand Up @@ -38,6 +39,7 @@ def create_app(self):
"""
app = Flask(__name__)
app.requests_session = requests.Session()
app.config.from_object(DefaultConfig())

# Add Routes
@app.route('/')
Expand Down Expand Up @@ -70,6 +72,8 @@ def run(self, host='localhost', port=8810, workers=1, dev=False):

# Run flask as a development server
if (dev == True):
self.app.config.from_object(DevelopmentConfig())

command = [
'flask',
'--app', 'main',
Expand All @@ -80,6 +84,8 @@ def run(self, host='localhost', port=8810, workers=1, dev=False):
]
# Run flask as a production server
else:
self.app.config.from_object(ProductionConfig())

command = [
'gunicorn',
'-b', f'{host}:{port}',
Expand Down