I am using flask to create a website. I want to take an input from a slider and then depending on the output from the slider send the website user to a different page. For example if they input 10 into the slider send them to a page specifically designed for 10.
Here is my python code:
#imports flask
from flask import Flask
#Imports templates so we can use html
from flask import render_template
from flask import request
from markupsafe import escape
app = Flask(__name__)
@app.route("/")
def test():
return render_template('main.html')
@app.route("/slider/")
def Slider():
return "<p>Slideeeeeeeeeeeee!</p>"
@app.route('/user/<output>')
def show_user_profile(output):
# show the user profile for that user
return f'User {escape(output)}'
Here is my HTML code:
<!DOCTYPE html>
<html>
<head>
<style>
body {background-color: rgb(184, 251, 159);}
body {font-family: 'Century Gothic', monospace;}
h1 {color: rgb(0, 0, 0);}
h1 {font-family: 'Century Gothic', monospace;}
p {color: rgb(0, 0, 0);}
p {font-family: 'Century Gothic', monospace;}
form {color: rgb(0, 0, 0);}
form {font-family: 'Century Gothic', monospace;}
</style>
</head>
<body>
<h1>Sprout</h1>
<!--Slider-->
<div class="slider">
<input type="range" min="0" max="10" value="5" oninput="output.innerText = this.value">
<p id="output">5</p>
</div>
</body>
</html>
The slider part in the HTML is the slider.
I tried just directly calling the output variable in python because they are in the same folder but that doesn't work.