I'm new in python / flask, so I'm probably not solving the issue the way it should be solved... Considering this, the question is:
I have a flask def(), which gets a POST from an HTML, and returns the text "File successfully processed".
What I want is for the "File successfully processed" to have the style in my styles.css file.
PS.: I already have an index.html which works great with the styles.css. The code in index.html is:
<head>
<link rel= "stylesheet" type= "text/css" href= "{{ url_for('static',filename='css/styles.css') }}">
</head>
So, how do I apply this styles.css to the return "File successfully processed"?
@app.route("/run_ctb", methods=["GET", "POST"])
def web_run_ctb():
if request.method == "POST":
return "<p>File successfully processed<p>"
That styles sheet is currently only applying to your index.html template. You should create a template for your "/run_ctb" page, for example called run_ctb.html which would look like:
<head>
<link rel= "stylesheet" type= "text/css" href= "{{
url_for('static',filename='css/styles.css') }}">
</head>
<body>
<p>File successfully processed<p>
</body>
Then you can just have your route function render the template:
@app.route("/run_ctb", methods=["GET", "POST"])
def web_run_ctb():
if request.method == "POST":
return render_template('run_ctb.html')