Cannot pass a variable given from url to route's callback fucntion and redirect issue

9 views
Skip to first unread message

nikos.at....@gmail.com

unread,
Aug 30, 2018, 5:15:18 AM8/30/18
to modwsgi
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 

Graham Dumpleton

unread,
Aug 30, 2018, 5:36:03 AM8/30/18
to mod...@googlegroups.com
I gather this is just a Flask question since in other email you say you can't get mod_wsgi working. For Flask questions better to ask on a Flask list or on StackOverflow.

Graham

--
You received this message because you are subscribed to the Google Groups "modwsgi" group.
To unsubscribe from this group and stop receiving emails from it, send an email to modwsgi+u...@googlegroups.com.
To post to this group, send email to mod...@googlegroups.com.
Visit this group at https://groups.google.com/group/modwsgi.
For more options, visit https://groups.google.com/d/optout.

Νίκος @ SuperHost

unread,
Aug 30, 2018, 7:10:37 AM8/30/18
to mod...@googlegroups.com
Please since you know the problem iam facing, please take a loot because i saw on stackoverflow that you are also deep in python3 knowledge.
At least only for the (1) question

Its very simple for someone who knows.

You received this message because you are subscribed to a topic in the Google Groups "modwsgi" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/modwsgi/RdF_jP6_KE0/unsubscribe.
To unsubscribe from this group and all its topics, send an email to modwsgi+u...@googlegroups.com.

Graham Dumpleton

unread,
Aug 30, 2018, 7:12:02 AM8/30/18
to mod...@googlegroups.com
I don't know how to use Flask that much. I am the wrong person to ask.

Νίκος @ SuperHost

unread,
Aug 30, 2018, 7:23:58 AM8/30/18
to mod...@googlegroups.com
Okey.
In StackOverflow iam tryign to put the above code with ctrl-k and it doesnt let me post it. It says that myh oce is not properly formatted as code althogh i have it with 4 spaces or ctrk-k. its been half an hour and i can't even post there/.
Any ideas?
Reply all
Reply to author
Forward
0 new messages