Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Flask Issues
#11
(Oct-28-2016, 05:17 PM)snippsat Wrote: In a css file "url_for" will not work,and will give error as you get.
/python]

Cheers for the reply snippsat, i tried what you suggested, couldn't get it to work still after trying for a couple of hours so decied to go pure css styled buttons.

But then after a couple more hours playing and learning, found a few more limitations of flask that I couldn't live with. So today I am starting to tackle at starting again with django.

Wish me luck.
Reply
#12
Quote:But then after a couple more hours playing and learning, found a few more limitations of flask that I couldn't live with. So today I am starting to tackle at starting again with django.
The limitations is not on Flask,it's on your side Wink 
It's the same in Django,so that wont help.
Flask is also a better choice for Raspberry Pi.

Can take the basic of this.
Look at this Pen with you css code.
So here use url link for images,
If want to use images from disk has to load them from server.

Here the same in Flask.
Folder setup:
button_img\
app.py
  templates\
  index.html
  static\
    css\
    style.css
    images\
    owl.jpg
    round.gif
app.py:
from flask import Flask, render_template

app = Flask(__name__, static_url_path='')

@app.route("/")
def bak_image():
    return render_template("index.html")

if __name__ == '__main__':
    app.run()
index.html:
<html>
  <head>
    <link rel=stylesheet type=text/css href="{{ url_for('static', filename='css/style.css') }}" />    
  </head>
  <body>  
    <p>Does button work?</p>
    <button id=submit type="submit" value="Submit"></button>    
  </body>
</html>
style.css:
#submit {
  color: #fff;
  font-size: 0;
  width: 80px;
  height: 80px;
  border: none;
  margin: 0;
  padding: 0;
  background-image: url('../images/owl.jpg');
  background-repeat: no-repeat;
}

#submit:hover {
  background-image: url('../images/round.gif');
  background-repeat: no-repeat;
}
Reply
#13
(Oct-29-2016, 04:09 PM)snippsat Wrote: The limitations is not on Flask,it's on your side Wink

Lol never a truer word spoken.

Thank you, using the above it is working, you're a star.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  flask issues with app structuring sidk23396 1 1,713 Feb-12-2020, 11:41 PM
Last Post: Larz60+

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020