Python Forum
Thread Rating:
  • 2 Vote(s) - 3 Average
  • 1
  • 2
  • 3
  • 4
  • 5
unable to call function in Flask
#1
Hello everyone
i am trying to call function from another function but unfortunately it doesn't work
here is my code... The app starts and it doesn't ask for dir name as i was expecting

from flask import Flask,render_template
from os import listdir
from os.path import join,isfile

app = Flask(__name__)

def ask_for_dir():
    dirpath=raw_input("please provide dirname for gallery")
    spisak={}
    for i in listdir(dirpath):
        pat=join(dirpath,i)
        if isfile(pat) and pat.endswith("jpg") or pat.endswith("jpeg"):
            spisak[i]=pat
        else:
            continue
    return spisak

@app.route('/')
def hello_world():
    spisak=ask_for_dir()
    lensp=len(spisak)
    return render_template("gal2.html",lensp=lensp,spisak=spisak)


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


Messages In This Thread
unable to call function in Flask - by verb - Sep-28-2016, 07:38 PM
RE: unable to call function in Flask - by nilamo - Sep-28-2016, 08:10 PM
RE: unable to call function in Flask - by snippsat - Sep-28-2016, 08:56 PM
RE: unable to call function in Flask - by verb - Sep-29-2016, 06:13 AM
RE: unable to call function in Flask - by verb - Sep-29-2016, 01:59 PM
RE: unable to call function in Flask - by nilamo - Sep-29-2016, 02:27 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Flask run function in background and auto refresh page raossabe 2 7,719 Aug-20-2022, 10:00 PM
Last Post: snippsat
  IndexError: list index out of range" & "TypeError: The view function f: Flask Web App joelbeater992 5 3,576 Aug-31-2021, 08:08 PM
Last Post: joelbeater992
  gettin flask to call script periodically GrahamL 1 2,253 Jan-08-2021, 06:11 PM
Last Post: ndc85430
  how to pass javascript variables to url_for function in a flask template experimental 5 6,455 Oct-29-2020, 03:29 AM
Last Post: universe
  Flask Create global response function to be called from every where in the web app umen 2 2,340 Apr-14-2020, 09:54 PM
Last Post: umen
  flask-SQLAlchemy query with keyword as function argument pascale 2 3,519 Mar-13-2019, 08:45 PM
Last Post: Ecniv

Forum Jump:

User Panel Messages

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