File size: 1,409 Bytes
f56e71d
1936a50
f56e71d
1936a50
c3cc0a9
f56e71d
c3cc0a9
 
 
 
 
f56e71d
 
 
c3cc0a9
 
1936a50
 
 
 
 
 
 
 
 
 
 
 
 
 
f56e71d
 
c3cc0a9
f56e71d
 
 
 
 
 
 
 
 
 
 
c3cc0a9
f56e71d
c3cc0a9
f56e71d
 
c3cc0a9
f56e71d
 
1936a50
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
import os
from dotenv import load_dotenv
from flask import Flask, jsonify
from routes import api_bp
import logging
from datetime import datetime

# Configure logging
logging.basicConfig(
    level=logging.INFO,
    format='%(asctime)s - %(name)s - %(levelname)s - %(message)s',
    handlers=[
        logging.StreamHandler()
    ]
)

logger = logging.getLogger(__name__)

# Add debug logging for .env file
current_dir = os.path.dirname(os.path.abspath(__file__))
env_path = os.path.join(current_dir, '.env')
logger.info(f"Looking for .env file at: {env_path}")
logger.info(f"File exists: {os.path.exists(env_path)}")

# Load environment variables before creating the app
load_dotenv(env_path)

# Add debug logging for environment variable
logger.info(f"HUGGINGFACE_API_TOKEN after loading: {'HUGGINGFACE_API_TOKEN' in os.environ}")

def create_app():
    app = Flask(__name__)
    
    # Register blueprints
    app.register_blueprint(api_bp, url_prefix='/api')
    
    # Home route
    @app.route('/')
    def home():
        return jsonify({
            'status': 'online',
            'timestamp': datetime.utcnow().isoformat(),
            'message': 'Welcome to the Hostel Management API'
        })
    
    return app

# This is for both local and production
app = create_app()

if __name__ == '__main__':
    port = int(os.environ.get('PORT', 7860))
    app.run(host='0.0.0.0', port=port, debug=True)