-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
95 lines (77 loc) · 2.28 KB
/
main.py
File metadata and controls
95 lines (77 loc) · 2.28 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
90
91
92
93
94
95
#!/usr/bin/env python3
"""
Job Scraper Application
This is the main entry point for the Job Scraper application.
It creates and runs the Flask application.
Usage:
python3 main.py [options]
Note:
This project uses 'python3' as the standard command.
If you encounter 'command not found' errors, please see
PYTHON_COMMAND_GUIDE.md for troubleshooting steps.
"""
import argparse
import os
import logging
from app import create_app
def parse_args():
"""
Parse command line arguments.
Returns:
Parsed arguments
"""
parser = argparse.ArgumentParser(description='Job Scraper Application')
parser.add_argument(
'--config',
type=str,
default=os.environ.get('CONFIG_PATH', 'config/api_config.yaml'),
help='Path to configuration file (default: config/api_config.yaml)'
)
parser.add_argument(
'--host',
type=str,
default=os.environ.get('FLASK_RUN_HOST', '0.0.0.0'),
help='Host to bind to (default: 0.0.0.0)'
)
parser.add_argument(
'--port',
type=int,
default=int(os.environ.get('FLASK_RUN_PORT', 5000)),
help='Port to bind to (default: 5000)'
)
parser.add_argument(
'--debug',
action='store_true',
default=os.environ.get('FLASK_DEBUG', '0') == '1',
help='Enable debug mode'
)
return parser.parse_args()
def setup_logging():
"""Set up basic logging configuration."""
logging.basicConfig(
level=logging.INFO,
format='%(asctime)s - %(name)s - %(levelname)s - %(message)s',
datefmt='%Y-%m-%d %H:%M:%S'
)
def main():
"""Main entry point for the application."""
# Parse command line arguments
args = parse_args()
# Set up logging
setup_logging()
# Create logger
logger = logging.getLogger('job_scraper')
# Log startup information
logger.info(f"Starting Job Scraper application with config: {args.config}")
logger.info(f"Debug mode: {'Enabled' if args.debug else 'Disabled'}")
# Create Flask app
app = create_app(config_path=args.config)
# Run the app
app.run(
host=args.host,
port=args.port,
debug=args.debug,
use_reloader=args.debug
)
if __name__ == '__main__':
main()