35 lines
1.0 KiB
Python
35 lines
1.0 KiB
Python
from flask import Flask, request, jsonify
|
|
from ticket_handler import process_submission
|
|
import logging
|
|
|
|
app = Flask(__name__)
|
|
logging.basicConfig(level=logging.INFO)
|
|
|
|
@app.route("/contact", methods=["POST"])
|
|
def contact():
|
|
data = request.get_json() or {}
|
|
try:
|
|
full_name = data.get("name", "").strip()
|
|
email = data.get("email", "").strip()
|
|
message = data.get("message", "").strip()
|
|
|
|
# split full name
|
|
parts = full_name.split()
|
|
first_name = parts[0] if parts else ""
|
|
last_name = " ".join(parts[1:]) if len(parts) > 1 else ""
|
|
|
|
process_submission({
|
|
"first_name": first_name,
|
|
"last_name": last_name,
|
|
"email": email,
|
|
"message": message
|
|
})
|
|
|
|
return jsonify({"status": "success"}), 200
|
|
except Exception as e:
|
|
logging.exception("❌ Error in /contact:")
|
|
return jsonify({"status": "error", "message": str(e)}), 500
|
|
|
|
if __name__ == "__main__":
|
|
app.run(host="0.0.0.0", port=8000)
|