so I have tried paying some tutors to look at this and they cannot seem to find the issue. I have a really good feeling it is a directory issue.
App.py is outside all folders, inside a template folder is pricing.html, outside is another folder named css which has pricing.css.
I run my app.py which loads pricing.html to be able to press a button which goes to stripe checkout. The issue is, app.py finds the pricing folder, but the pricing.css does not load. Here is the html code in pricing.html:
<link rel="stylesheet" type="text/css" href="/css/style.css" media="screen">
Here is the app.py code:
from flask import Flask, redirect, request, render_template
import stripe
app = Flask(__name__,static_url_path="",static_folder="templates")
stripe.api_key = 'sk_test_51KzqK9Hj2B2Quz911XrP11cB4Jb2ESrDCelSpRIZBqa18TWO9bGKlyuWsmiNeGYEHw4224xx5ghUWDaTQOukRjcf00rHXcZGYU'
YOUR_DOMAIN = "http://localhost:5000"
@app.route('/create-checkout-session', methods=['POST'])
def create_checkout_session():
try:
checkout_session = stripe.checkout.Session.create(
line_items = [
{
'price': 'price_1KzrAtHj2B2Quz91wMDanJjz',
'quantity':1
}
],
mode="payment",
success_url=YOUR_DOMAIN + "/success.html",
cancel_url=YOUR_DOMAIN + "/cancel.html"
)
except Exception as e:
return str(e)
return redirect(checkout_session.url,code=303)
if __name__== "__main__":
app.run(port=5000,debug=True)
If I move the css folder inside the templates folder, the css will load, but I would have to change the html to all the other template and also I like this folder organization. Any thoughts?
Here is what is returned in terminal when I run it:
-
- [20/May/2022 18:04:50] "GET /pricing.html HTTP/1.1" 200 -
-
- [20/May/2022 18:04:51] "GET /css/style.css HTTP/1.1" 404 -
-
- [20/May/2022 18:04:51] "GET /css/Pricing.css HTTP/1.1" 404 -
-
- [20/May/2022 18:04:51] "GET /javascript/jquery.js HTTP/1.1" 404 -
-
- [20/May/2022 18:04:51] "GET /javascript/nicepage.js HTTP/1.1" 404 -
-
- [20/May/2022 18:04:51] "GET /css/images/GainesOpusInstitute4.png HTTP/1.1" 404 -