Spaces:
Sleeping
Sleeping
Update server.py
Browse files
server.py
CHANGED
@@ -1,5 +1,6 @@
|
|
1 |
from fastapi import FastAPI, HTTPException
|
2 |
from fastapi.middleware.cors import CORSMiddleware
|
|
|
3 |
from pydantic import BaseModel
|
4 |
import stripe
|
5 |
|
@@ -14,6 +15,9 @@ app.add_middleware(
|
|
14 |
allow_headers=["*"],
|
15 |
)
|
16 |
|
|
|
|
|
|
|
17 |
# Set your Stripe secret key
|
18 |
stripe.api_key = "sk_test_51P2EfNIS4MdDIAjNEABa0PlwvzI7GgHdEGtCzCNPG0hDODhI8qz46TqRbUvFYSTvAsnneCnW0UNlWLubpZ0TQqxo00VUTUTc3n"
|
19 |
|
@@ -41,8 +45,8 @@ async def create_checkout_session(checkout: CheckoutRequest):
|
|
41 |
}],
|
42 |
mode='payment',
|
43 |
customer_email=checkout.email,
|
44 |
-
success_url="
|
45 |
-
cancel_url="
|
46 |
)
|
47 |
return {"url": session.url}
|
48 |
except Exception as e:
|
|
|
1 |
from fastapi import FastAPI, HTTPException
|
2 |
from fastapi.middleware.cors import CORSMiddleware
|
3 |
+
from fastapi.staticfiles import StaticFiles
|
4 |
from pydantic import BaseModel
|
5 |
import stripe
|
6 |
|
|
|
15 |
allow_headers=["*"],
|
16 |
)
|
17 |
|
18 |
+
# Serve static files
|
19 |
+
app.mount("/static", StaticFiles(directory="static"), name="static")
|
20 |
+
|
21 |
# Set your Stripe secret key
|
22 |
stripe.api_key = "sk_test_51P2EfNIS4MdDIAjNEABa0PlwvzI7GgHdEGtCzCNPG0hDODhI8qz46TqRbUvFYSTvAsnneCnW0UNlWLubpZ0TQqxo00VUTUTc3n"
|
23 |
|
|
|
45 |
}],
|
46 |
mode='payment',
|
47 |
customer_email=checkout.email,
|
48 |
+
success_url="http://127.0.0.1:8000/static/success.html", # Replace with your success URL
|
49 |
+
cancel_url="http://127.0.0.1:8000/static/failure.html", # Replace with your failure URL
|
50 |
)
|
51 |
return {"url": session.url}
|
52 |
except Exception as e:
|