Python Forum
How do you define and -put a value into a variable in Flask?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How do you define and -put a value into a variable in Flask?
#9
I change my code a bit and that has more issues. I bet they are basic I don't see the issues. Its too new to me still.

I added a login page which must always be the first page. It will not display the page but displays index1.html.

import os
from flask import Flask, render_template, request, redirect
from datetime import datetime
from os import environ

app = Flask(__name__)

@app.route('/login')
@app.route('/')
def login():
    
    if request.method == ['POST', 'GET']:
        return render_template('login.html', username=username, password=password)
    else:
        return render_template('index1.html')

@app.route('/index1')
def index1():
    if request.method == ['POST', 'GET']:
        mdate_now = str(datetime.now().date)
        return render_template('index1.html')
    else:
        return render_template('index1.html')


if __name__ == "__main__":
    app.run(debug=True)

    driver = "IBM i Access ODBC Driver"
    system = 'a4gi501'
    username = 'myID'
    password = 'myPassword' 
    connect_ibm = 'DRIVER=' + driver + ';SYSTEM=' + system + ';UID=' + username + ';PASSWORD=' + password
[html]
{% extends "base.html" %} {% block title %}Login{% endblock %} {% block content
%}
<form method="POST">
<h3 align="center">Login</h3>
<div class="form-group">
<label for="email">User ID</label>
<input
type="text"
class="form-control"
id="username"
name="username"
placeholder="User Name"
/>
</div>
<div class="form-group">
<label for="password">Password</label>
<input
type="password"
class="form-control"
id="password"
name="password"
placeholder="Enter password"
/>
</div>
<br />
<button type="submit" class="btn btn-primary">Login</button>
</form>
{% endblock %}
[/html]
Reply


Messages In This Thread
RE: How do you define and -put a value into a variable in Flask? - by a4ginatl - Aug-14-2021, 08:09 PM

Forum Jump:

User Panel Messages

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