Spaces:
Sleeping
Sleeping
File size: 2,576 Bytes
01780bf bb51932 01780bf a1cfef6 01780bf a1cfef6 6ddba4d 01780bf 2fab7d3 1aa8118 3480da8 9d5c08a 2fab7d3 3480da8 5ef3837 bb51932 17b12ba bb51932 9d5c08a 3480da8 bb51932 9d5c08a 1aa8118 5ef3837 1aa8118 9d5c08a 1aa8118 9d5c08a c32f608 9d5c08a 1aa8118 5ef3837 1aa8118 9d5c08a 1aa8118 9d5c08a efa0646 9d5c08a 1aa8118 5ef3837 9d5c08a efa0646 9d5c08a 2fab7d3 bb51932 a1cfef6 |
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 |
import torch
from flask import Flask, render_template, request, jsonify, redirect, session, url_for
import json
import os
from transformers import pipeline
from gtts import gTTS
from pydub import AudioSegment
from pydub.silence import detect_nonsilent
from transformers import AutoConfig
import time
from waitress import serve
from simple_salesforce import Salesforce
import requests
# Initialize Flask app
app = Flask(__name__, template_folder="templates")
app.secret_key = os.urandom(24)
# β
Enable Debug Mode
app.config["DEBUG"] = True
# β
Salesforce Connection Setup
try:
print("Attempting to connect to Salesforce...")
sf = Salesforce(username='[email protected]',
password='Sati@1020',
security_token='sSSjyhInIsUohKpG8sHzty2q')
print("β
Connected to Salesforce successfully!")
except Exception as e:
print(f"β Failed to connect to Salesforce: {str(e)}")
# β
ROUTE: List All Routes for Debugging
@app.route("/routes", methods=["GET"])
def list_routes():
routes = []
for rule in app.url_map.iter_rules():
routes.append({"endpoint": rule.endpoint, "route": str(rule)})
return jsonify({"available_routes": routes})
# β
HOME ROUTE
@app.route("/", methods=["GET"])
def home():
return jsonify({"message": "Welcome to Biryani Hub API. Use /register, /login, /menu, /index, or /routes to check available endpoints."})
# β
RENDER INDEX.HTML FOR REGISTER & LOGIN
@app.route("/index", methods=["GET"])
def index_page():
return render_template("index.html")
# β
REGISTER API
@app.route("/register", methods=["POST"])
def register():
print("β‘ Register API hit")
data = request.json
if not data or "name" not in data or "email" not in data or "phone" not in data:
return jsonify({"error": "Missing required fields"}), 400
return jsonify({"success": True, "message": "Registration successful"})
# β
LOGIN API
@app.route("/login", methods=["POST"])
def login():
print("β‘ Login API hit")
data = request.json
if not data or "email" not in data or "phone" not in data:
return jsonify({"error": "Missing email or phone"}), 400
return jsonify({"success": True, "message": "Login successful"})
# β
MENU API
@app.route("/menu", methods=["GET"])
def get_menu():
print("β‘ Menu API hit")
return jsonify({"success": True, "menu": [{"name": "Biryani", "price": 10}]})
# β
START SERVER
if __name__ == "__main__":
print("β
Starting Flask API Server on port 7860...")
serve(app, host="0.0.0.0", port=7860)
|