Sep-28-2016, 07:38 PM
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
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)
