On Wednesday, August 29, 2018 at 10:57:35 AM UTC-6, Νίκος Βέργος wrote: > Flask app.py > ================== > @app.route( '/' ) > @app.route( '/<page>' ) > def index( page ): > > # use the variable form template for displaying > counter = '''<center> > <table bgcolor=black bordercolor=orangered> > td><font size=3 color=lime> Αριθμός Επισκεπτών: </font></td> > <td><a href="{{ url_for( '/log', page='%s' ) }}"><font size=3 color=plum> %d > </font></a></td> > </table> > ''' % (page, pagehit) > > if page != 'index.html': > pdata = redirect( 'http://superhost.gr/cgi-bin/' + page ) > return pdata > > > Template ndex.html > ================== > <div align=right> > <a href="{{ url_for( '/', page='some_value' ) }}"> <img > src="/static/images/π.gif"> </a> > </div> > > <a href="{{ url_for( '/', page='another_value' ) }}"> <img > src="/static/images/download.gif"></a> > > > 1. All i want ro do is when the user clicks on the images within the html > tamplate, to pass those variables value to '/' route so to perfrom then asome > action with those values > > The error iam receiving is this: > =============================== > builtins.TypeError > TypeError: index() missing 1 required positional argument: 'page' > > I mean i do have <page> declared in route and also do have 'page' as > variable to the callback fucntion, why cant it see it? > > 2. Also about the redirect funtion iam using... is there a way to get back > the HTML response of running that cgi-scrit and then add another HTML value > to that response? I used subprocess and Response but they weren able to > deliver the content back the pdata variable for display. > What i actually want to do among other things is from within my flask app > script to try to run and get theresponse back of a cgi-script
I haven't looked at your problem in detail (I seldom read this group anymore) but I think you want something like: def index( page='myhomepage' ): If the function gets called via the "/" url, there will be no 'page' argument so you need to write the function signature to make that argument optional. No idea about question #2. -- https://mail.python.org/mailman/listinfo/python-list