-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfig.py
49 lines (38 loc) · 1.14 KB
/
config.py
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
40
41
42
43
44
45
46
47
48
49
"""
Configuration settings for MarkItDown Converter
"""
import os
from pathlib import Path
class Config:
# Application paths
BASE_DIR = Path(__file__).parent
UPLOAD_FOLDER = BASE_DIR / 'uploads'
# File handling
MAX_CONTENT_LENGTH = 16 * 1024 * 1024 # 16MB max-limit
ALLOWED_IMAGE_EXTENSIONS = {'.png', '.jpg', '.jpeg', '.gif', '.webp'}
# API configuration
OPENAI_API_KEY = os.getenv('OPENAI_API_KEY')
OPENAI_MODEL = 'gpt-4o'
# Network settings
HOST = '0.0.0.0'
PORT = 8080
REQUEST_TIMEOUT = 10
# Development settings
DEBUG = os.getenv('QUART_ENV') == 'development'
@classmethod
def init_app(cls, app):
cls.UPLOAD_FOLDER.mkdir(exist_ok=True)
app.config['MAX_CONTENT_LENGTH'] = cls.MAX_CONTENT_LENGTH
app.config['DEBUG'] = cls.DEBUG
class DevelopmentConfig(Config):
DEBUG = True
class ProductionConfig(Config):
DEBUG = False
config = {
'development': DevelopmentConfig,
'production': ProductionConfig,
'default': DevelopmentConfig
}
def get_config():
env = os.getenv('QUART_ENV', 'development')
return config.get(env, config['default'])