Update app.py
Browse files
app.py
CHANGED
|
@@ -50,6 +50,8 @@ def generate_coupon_code(length=10):
|
|
| 50 |
return ''.join(random.choice(characters) for _ in range(length))
|
| 51 |
|
| 52 |
|
|
|
|
|
|
|
| 53 |
import re
|
| 54 |
|
| 55 |
@app.route("/order-history", methods=["GET"])
|
|
@@ -70,11 +72,17 @@ def order_history():
|
|
| 70 |
|
| 71 |
orders = result.get("records", []) # Fetch all orders
|
| 72 |
|
| 73 |
-
# Strip image URLs from order details
|
| 74 |
for order in orders:
|
| 75 |
order_details = order.get("Order_Details__c", "")
|
| 76 |
# Remove image URLs using regex
|
| 77 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 78 |
|
| 79 |
return render_template("order_history.html", orders=orders)
|
| 80 |
|
|
@@ -86,6 +94,7 @@ def order_history():
|
|
| 86 |
|
| 87 |
|
| 88 |
|
|
|
|
| 89 |
@app.route("/signup", methods=["GET", "POST"])
|
| 90 |
def signup():
|
| 91 |
if request.method == "POST":
|
|
|
|
| 50 |
return ''.join(random.choice(characters) for _ in range(length))
|
| 51 |
|
| 52 |
|
| 53 |
+
import re
|
| 54 |
+
|
| 55 |
import re
|
| 56 |
|
| 57 |
@app.route("/order-history", methods=["GET"])
|
|
|
|
| 72 |
|
| 73 |
orders = result.get("records", []) # Fetch all orders
|
| 74 |
|
| 75 |
+
# Strip image URLs from order details and split remaining data by new lines
|
| 76 |
for order in orders:
|
| 77 |
order_details = order.get("Order_Details__c", "")
|
| 78 |
# Remove image URLs using regex
|
| 79 |
+
cleaned_details = re.sub(r'http[s]?://\S+', '', order_details)
|
| 80 |
+
|
| 81 |
+
# Now split the cleaned details by lines and join them with <br> to create line breaks
|
| 82 |
+
cleaned_details = cleaned_details.replace("\n", "<br>")
|
| 83 |
+
|
| 84 |
+
# Update the order details with the cleaned and formatted details
|
| 85 |
+
order['Order_Details__c'] = cleaned_details
|
| 86 |
|
| 87 |
return render_template("order_history.html", orders=orders)
|
| 88 |
|
|
|
|
| 94 |
|
| 95 |
|
| 96 |
|
| 97 |
+
|
| 98 |
@app.route("/signup", methods=["GET", "POST"])
|
| 99 |
def signup():
|
| 100 |
if request.method == "POST":
|