-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.py
More file actions
89 lines (71 loc) · 2.31 KB
/
Copy pathapp.py
File metadata and controls
89 lines (71 loc) · 2.31 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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
#!/usr/bin/env python3
"""
Record en Transcribe App - Hoofdapplicatie
Dit is het hoofdbestand van de applicatie dat de Flask webserver start
en alle modules initialiseert.
"""
import os
import logging
from logging.handlers import RotatingFileHandler
from flask import Flask, render_template, request
from modules.web_interface import init_app
def configure_logging(app):
"""
Configureert logging voor de applicatie.
Args:
app: Flask applicatie-instantie
"""
# Zorg ervoor dat de logs map bestaat
if not os.path.exists('logs'):
os.mkdir('logs')
# Configureer file handler voor logs
file_handler = RotatingFileHandler(
'logs/app.log',
maxBytes=10485760, # 10MB
backupCount=10
)
file_handler.setFormatter(logging.Formatter(
'%(asctime)s %(levelname)s: %(message)s [in %(pathname)s:%(lineno)d]'
))
file_handler.setLevel(logging.INFO)
# Configureer console handler voor logs
console_handler = logging.StreamHandler()
console_handler.setFormatter(logging.Formatter('%(levelname)s: %(message)s'))
console_handler.setLevel(logging.INFO)
# Voeg handlers toe aan de app logger
app.logger.addHandler(file_handler)
app.logger.addHandler(console_handler)
app.logger.setLevel(logging.INFO)
# Configureer root logger voor andere modules
logging.basicConfig(
handlers=[file_handler, console_handler],
level=logging.INFO
)
app.logger.info('Record en Transcribe App gestart')
def create_app():
"""
Creëert en configureert de Flask applicatie.
Returns:
Flask: Flask applicatie-instantie
"""
app = Flask(__name__)
# Configuratie van de app
app.config['SECRET_KEY'] = 'dev-key-should-be-changed-in-production'
app.config['MAX_CONTENT_LENGTH'] = 16 * 1024 * 1024 # 16MB max upload
# Configureer logging
configure_logging(app)
# Log verzoeken
@app.before_request
def log_request_info():
app.logger.info(f'Request: {request.method} {request.path} {request.remote_addr}')
# Registreer de web interface module
init_app(app)
return app
def main():
"""
Start de Flask applicatie.
"""
app = create_app()
app.run(debug=True)
if __name__ == '__main__':
main()