Download app.py from Nikpatil/Email_Classification_For_Support_Team: direct link, hf CLI and curl.
- Browser
- Download file 1.05 kB
-
https://huggingface.co/spaces/Nikpatil/Email_Classification_For_Support_Team/resolve/main/app.py
- Command line
-
hf download hf://spaces/Nikpatil/Email_Classification_For_Support_Team/app.py
-
curl -L -o app.py https://huggingface.co/spaces/Nikpatil/Email_Classification_For_Support_Team/resolve/main/app.py
1.05 kB
| import logging | |
| from flask import Flask, jsonify | |
| from api import api_bp | |
| # Configure logging | |
| logging.basicConfig( | |
| level=logging.INFO, | |
| format='%(asctime)s - %(name)s - %(levelname)s - %(message)s' | |
| ) | |
| logger = logging.getLogger(__name__) | |
| # Create and configure Flask app | |
| app = Flask(__name__) | |
| app.register_blueprint(api_bp) | |
| # Add error handlers | |
| def not_found(error): | |
| return jsonify({"error": "Endpoint not found"}), 404 | |
| def method_not_allowed(error): | |
| return jsonify({"error": "Method not allowed"}), 405 | |
| def server_error(error): | |
| logger.error(f"Internal server error: {error}") | |
| return jsonify({"error": "Internal server error"}), 500 | |
| def home(): | |
| return jsonify({ | |
| "status": "online", | |
| "message": "Email Classification API is running. Use the /classify endpoint to classify emails." | |
| }) | |
| if __name__ == "__main__": | |
| logger.info("Starting Email Classification API server...") | |
| app.run(host="0.0.0.0", port=7860) |