ich habe das Problem, dass ich von meinem Python-Code einen Parameter an das Template übergeben möchte, dass allerdings nicht funktioniert.
Mein Python-Code:
Code: Alles auswählen
from flask import Flask, url_for, render_template, request
import requests
from bs4 import BeautifulSoup
import csv
app = Flask(__name__)
@app.route("/")
def index():
return render_template('index.html', tor="TOR")
@app.route("/login", methods=['POST', 'GET'])
def login():
name = ""
if request.method == 'POST':
name = request.form['name']
else:
name == request.args.get('name')
return "Hallo "+name+"!"
if __name__ == '__main__':
app.run(port=1337, debug=True)
Code: Alles auswählen
<!DOCTYPE html>
<html>
<body>
<h1>{{ tor }}</h1>
<form action="http://localhost:1337/login" method="POST">
<p>Name:</p>
<p><input type="text" name="name" /></p>
<p><input type="submit" value="Submit" /></p>
</form>
</body>
</html>