I used bootstrap studio to create an HTML
page that I need to use for flask
.
The HTML page was running fine with all assets working from asset
directory.
I set up the flask app.py
, moved the /asset
dir with index.html
to /templates
and render_template
in the flask. HTML is loading but getting missing assets.
I read a blog and copied the asset folder to the /static
directory but not working.
Here is app.py
from flask import Flask, render_template
app = Flask(__name__)
@app.route("/")
def index():
games = ['Assassin', 'Call of Duty', 'Cyberpunk', "GTA V"]
return render_template("home.html", games=games)
if __name__ == "__main__":
app.run(debug= True)
Here is the output
* Detected change in 'c:\\Users\\Haseeb\\OneDrive\\Documents\\MEGAsync\\Freelancing\\Cars Classified market crawler - Ahmed\\web app\\app.py', reloading
* Restarting with stat
* Debugger is active!
* Debugger PIN: 238-233-787
* Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)
127.0.0.1 - - [12/Aug/2021 00:26:38] "GET / HTTP/1.1" 200 -
127.0.0.1 - - [12/Aug/2021 00:26:38] "GET /assets/bootstrap/css/bootstrap.min.css HTTP/1.1" 404 -
127.0.0.1 - - [12/Aug/2021 00:26:38] "GET /assets/fonts/font-awesome.min.css HTTP/1.1" 404 -
127.0.0.1 - - [12/Aug/2021 00:26:38] "GET /assets/fonts/ionicons.min.css HTTP/1.1" 404 -
127.0.0.1 - - [12/Aug/2021 00:26:38] "GET /assets/css/styles.min.css HTTP/1.1" 404 -
127.0.0.1 - - [12/Aug/2021 00:26:38] "GET /assets/bootstrap/js/bootstrap.min.js HTTP/1.1" 404 -
127.0.0.1 - - [12/Aug/2021 00:26:38] "GET /assets/img/cargurus_5744444c4a374742344641313533373039547565204a756c2032372031313a32373a30312032303231_4.jpg HTTP/1.1" 404 -
127.0.0.1 - - [12/Aug/2021 00:26:38] "GET /assets/img/autotrader_4a54444b42323055383833343538383832546875204a756c2031352031353a31353a33332032303231_4.jpg HTTP/1.1" 404 -
127.0.0.1 - - [12/Aug/2021 00:26:38] "GET /assets/img/autotrader_3554445a41323343323653343033353233546875204a756c2031352031353a31383a30322032303231_22.jpg HTTP/1.1" 404 -
127.0.0.1 - - [12/Aug/2021 00:26:38] "GET /assets/img/logo%20white.png HTTP/1.1" 404 -
This is how my tree is
Volume serial number is 4C25-00D7
C:.
│ app.py
│ website design.bsdesign
│
├───static
│ └───assets
│ ├───bootstrap
│ │ ├───css
│ │ │ bootstrap.min.css
│ │ │
│ │ └───js
│ │ bootstrap.min.js
│ │
│ ├───css
│ │ styles.min.css
│ │
│ ├───fonts
│ │ font-awesome.min.css
│ │ fontawesome-webfont.eot
│ │ fontawesome-webfont.svg
│ │ fontawesome-webfont.ttf
│ │ fontawesome-webfont.woff
│ │ fontawesome-webfont.woff2
│ │ FontAwesome.otf
│ │ ionicons.eot
│ │ ionicons.min.css
│ │ ionicons.svg
│ │ ionicons.ttf
│ │ ionicons.woff
│ │
│ └───img
│ adam-stefanca-hdMSxGizchk-unsplash.jpg
│ autotrader_3554445a41323343323653343033353233546875204a756c2031352031353a31383a30322032303231_22.jpg
│ autotrader_4a54444b42323055383833343538383832546875204a756c2031352031353a31353a33332032303231_4.jpg
│ cargurus_5744444c4a374742344641313533373039547565204a756c2032372031313a32373a30312032303231_4.jpg
│ logo white.png
│
└───templates
│ home.html
│ index.html
│ login.html
│
└───assets
├───bootstrap
│ ├───css
│ │ bootstrap.min.css
│ │
│ └───js
│ bootstrap.min.js
│
├───css
│ styles.min.css
│
├───fonts
│ font-awesome.min.css
│ fontawesome-webfont.eot
│ fontawesome-webfont.svg
│ fontawesome-webfont.ttf
│ fontawesome-webfont.woff
│ fontawesome-webfont.woff2
│ FontAwesome.otf
│ ionicons.eot
│ ionicons.min.css
│ ionicons.svg
│ ionicons.ttf
│ ionicons.woff
│
└───img
adam-stefanca-hdMSxGizchk-unsplash.jpg
autotrader_3554445a41323343323653343033353233546875204a756c2031352031353a31383a30322032303231_22.jpg
autotrader_4a54444b42323055383833343538383832546875204a756c2031352031353a31353a33332032303231_4.jpg
cargurus_5744444c4a374742344641313533373039547565204a756c2032372031313a32373a30312032303231_4.jpg
logo white.png