Created
June 19, 2020 10:57
-
-
Save minons1/24d839f45a28255e9e3dd19a1761fe85 to your computer and use it in GitHub Desktop.
Flask using static content
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!DOCTYPE html> | |
| <html lang="en"> | |
| <head> | |
| <meta charset="UTF-8"> | |
| <meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
| <title>Static content</title> | |
| <script src="{{url_for('static',filename='js/index.js')}}"></script> | |
| </head> | |
| <body> | |
| This is static content using flask | |
| <div id="text" onclick="rubah()"> | |
| this is from HTML | |
| </div> | |
| <img src="{{url_for('static', filename='images/miaw.jpeg')}}" alt=""> | |
| </body> | |
| </html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function rubah(){ | |
| document.getElementById('text').innerHTML = "This is from JavaScript"; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from flask import Flask,render_template | |
| app = Flask(__name__) | |
| @app.route('/') | |
| def index(): | |
| return "Static content flask for today" | |
| @app.route('/static') | |
| def static_method(): | |
| return render_template("static.html") | |
| if __name__ == "__main__": | |
| app.run() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment