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?
#3
(Aug-14-2021, 03:26 AM)ndc85430 Wrote: Show us the code and any errors - don't make us guess what the problem is!

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

app = Flask(__name__)

driver = "IBM i Access ODBC Driver"
system = 'a4gi501'
username = 'myID'
password = 'myPassword'
connect_ibm = 'DRIVER=' + driver + ';SYSTEM=' + system + ';UID=' + username + ';PASSWORD=' + password)

connection = pyodbc.connect('DRIVER=IBM i Access ODBC Driver;SYSTEM=a4gi501;UID=DFREINKEL;PWD=0urDogsandCats5;')

cursor = connection.cursor()


@app.route('/')
def index():
return render_template('/index.html')

if request.method == ['POST', 'GET']:
mdate_now = str(datetime.now().date)
return render_template('index.html')
else:
return render_template('index.html')


If I hardcode the values it works.
I also need it to run once at the beginning 0f the code.

TIA a4ginatl
Reply


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

Forum Jump:

User Panel Messages

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