librelist archives

« back to archive

Same URL pattern calling different view functions in Flask

Same URL pattern calling different view functions in Flask

From:
Sasa Trifunovic
Date:
2013-10-14 @ 16:37
I have URL related problem. I have index page and project page(on
which can be displayed one of many projects,depending on what
projectkey you pass as an argument). I want to have "pretty" urls so i
can have domainname.com/index and domainname.com/some_project_key
calling different view functions

@app.route('/')
@app.route('/index')
def index():
pass

@app.route('/<path:projectkey>')
def project(projectkey):
pass

This doesn't work for me because if i try going to the index page it
will go through index function but before it returns template it will
also run project function ,in which it will run query on non existing
project. Is there some built in solution for this or some workaround
is needed? Any help i can get is much appreciated.

Re: [flask] Same URL pattern calling different view functions in Flask

From:
Emanuil Tolev
Date:
2013-10-14 @ 16:54
Would it be OK for you to have a /projects/<key> route?

@app.route('/projects/<path:projectkey>')

I guess there's also the question "What if my app starts handling a
different type of record in the future?" e.g. /users/<username> to view
somebody's profile. Tying "/<something>" to mean "a specific project" would
prevent you from handling different kinds of records.

That's just an example of course, but apps will usually want to handle more
than one kind of record at some point.

Greetings,
Emanuil



On 14 October 2013 17:37, Sasa Trifunovic <sasa.s.trifunovic@gmail.com>wrote:

> I have URL related problem. I have index page and project page(on
> which can be displayed one of many projects,depending on what
> projectkey you pass as an argument). I want to have "pretty" urls so i
> can have domainname.com/index and domainname.com/some_project_key
> calling different view functions
>
> @app.route('/')
> @app.route('/index')
> def index():
> pass
>
> @app.route('/<path:projectkey>')
> def project(projectkey):
> pass
>
> This doesn't work for me because if i try going to the index page it
> will go through index function but before it returns template it will
> also run project function ,in which it will run query on non existing
> project. Is there some built in solution for this or some workaround
> is needed? Any help i can get is much appreciated.
>

Re: [flask] Same URL pattern calling different view functions in Flask

From:
Sasa Trifunovic
Date:
2013-10-14 @ 17:05
Hi,

Nope, it was like that in the beginning, and that way it works but  i
have to omit 'projects' part of the URL.
It's photography related site so different kind of record in the near
future is not planned.

BR
Sasa

On Mon, Oct 14, 2013 at 6:54 PM, Emanuil Tolev <emanuil@cottagelabs.com> wrote:
> Would it be OK for you to have a /projects/<key> route?
>
> @app.route('/projects/<path:projectkey>')
>
> I guess there's also the question "What if my app starts handling a
> different type of record in the future?" e.g. /users/<username> to view
> somebody's profile. Tying "/<something>" to mean "a specific project" would
> prevent you from handling different kinds of records.
>
> That's just an example of course, but apps will usually want to handle more
> than one kind of record at some point.
>
> Greetings,
> Emanuil
>
>
>
> On 14 October 2013 17:37, Sasa Trifunovic <sasa.s.trifunovic@gmail.com>
> wrote:
>>
>> I have URL related problem. I have index page and project page(on
>> which can be displayed one of many projects,depending on what
>> projectkey you pass as an argument). I want to have "pretty" urls so i
>> can have domainname.com/index and domainname.com/some_project_key
>> calling different view functions
>>
>> @app.route('/')
>> @app.route('/index')
>> def index():
>> pass
>>
>> @app.route('/<path:projectkey>')
>> def project(projectkey):
>> pass
>>
>> This doesn't work for me because if i try going to the index page it
>> will go through index function but before it returns template it will
>> also run project function ,in which it will run query on non existing
>> project. Is there some built in solution for this or some workaround
>> is needed? Any help i can get is much appreciated.
>
>

Re: [flask] Same URL pattern calling different view functions in Flask

From:
Emanuil Tolev
Date:
2013-10-14 @ 19:31
Trying to recreate your routes seems to actually work OK.

I created a new virtualenv to play with Flask in, using 64-bit Python 2.7.4
.
I then did
    pip install Flask
.
The latest Flask in pip seems to be 10.1 and installed the following
dependencies:

Flask==0.10.1
Jinja2==2.7.1
MarkupSafe==0.18
Werkzeug==0.9.4
argparse==1.2.1
itsdangerous==0.23
wsgiref==0.1.2


So, with that environment, I ran a minimal example:

from flask import Flask
app = Flask(__name__)

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

@app.route('/<path:projectkey>')
def project(projectkey):
    print 'this is executing'
    return 'project ' + projectkey

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


These are the responses I got:

$ curl http://localhost:5000/; echo
index
$ curl http://localhost:5000/index; echo
index
$ curl http://localhost:5000/aprojectkey; echo
project aprojectkey
# (and "this is executing" in the log)

That is to say, going to /index only triggered the index() function -
project() was not executed at all.
I'm not sure here, but this is probably due to Flask prioritising the
explicit route over the catch-all route.

I changed the order around too - defined project() first - it doesn't
matter, index() still got called on / and /index.

So you can go ahead and define these routes in your app, index() will work
as expected.
Although be careful not to allow the creation of a project with the name of
"index"...

Greetings,
Emanuil



On 14 October 2013 18:05, Sasa Trifunovic <sasa.s.trifunovic@gmail.com>wrote:

> Hi,
>
> Nope, it was like that in the beginning, and that way it works but  i
> have to omit 'projects' part of the URL.
> It's photography related site so different kind of record in the near
> future is not planned.
>
> BR
> Sasa
>
> On Mon, Oct 14, 2013 at 6:54 PM, Emanuil Tolev <emanuil@cottagelabs.com>
> wrote:
> > Would it be OK for you to have a /projects/<key> route?
> >
> > @app.route('/projects/<path:projectkey>')
> >
> > I guess there's also the question "What if my app starts handling a
> > different type of record in the future?" e.g. /users/<username> to view
> > somebody's profile. Tying "/<something>" to mean "a specific project"
> would
> > prevent you from handling different kinds of records.
> >
> > That's just an example of course, but apps will usually want to handle
> more
> > than one kind of record at some point.
> >
> > Greetings,
> > Emanuil
> >
> >
> >
> > On 14 October 2013 17:37, Sasa Trifunovic <sasa.s.trifunovic@gmail.com>
> > wrote:
> >>
> >> I have URL related problem. I have index page and project page(on
> >> which can be displayed one of many projects,depending on what
> >> projectkey you pass as an argument). I want to have "pretty" urls so i
> >> can have domainname.com/index and domainname.com/some_project_key
> >> calling different view functions
> >>
> >> @app.route('/')
> >> @app.route('/index')
> >> def index():
> >> pass
> >>
> >> @app.route('/<path:projectkey>')
> >> def project(projectkey):
> >> pass
> >>
> >> This doesn't work for me because if i try going to the index page it
> >> will go through index function but before it returns template it will
> >> also run project function ,in which it will run query on non existing
> >> project. Is there some built in solution for this or some workaround
> >> is needed? Any help i can get is much appreciated.
> >
> >
>

Re: [flask] Same URL pattern calling different view functions in Flask

From:
Sasa Trifunovic
Date:
2013-10-15 @ 00:39
Thanks for the help. Problem is with favicon.ico , browser is sending
GET request to /favicon.ico so project(projectkey) is called with
favicon.ico as an argument.

BR
Sasa

On Mon, Oct 14, 2013 at 9:31 PM, Emanuil Tolev <emanuil@cottagelabs.com> wrote:
> Trying to recreate your routes seems to actually work OK.
>
> I created a new virtualenv to play with Flask in, using 64-bit Python 2.7.4
> .
> I then did
>     pip install Flask
> .
> The latest Flask in pip seems to be 10.1 and installed the following
> dependencies:
>
> Flask==0.10.1
> Jinja2==2.7.1
> MarkupSafe==0.18
> Werkzeug==0.9.4
> argparse==1.2.1
> itsdangerous==0.23
> wsgiref==0.1.2
>
>
> So, with that environment, I ran a minimal example:
>
> from flask import Flask
> app = Flask(__name__)
>
>
> @app.route('/')
> @app.route('/index')
> def index():
>     return 'index'
>
>
> @app.route('/<path:projectkey>')
> def project(projectkey):
>     print 'this is executing'
>     return 'project ' + projectkey
>
> if __name__ == '__main__':
>     app.run(debug=True)
>
>
> These are the responses I got:
>
> $ curl http://localhost:5000/; echo
> index
> $ curl http://localhost:5000/index; echo
> index
> $ curl http://localhost:5000/aprojectkey; echo
> project aprojectkey
> # (and "this is executing" in the log)
>
> That is to say, going to /index only triggered the index() function -
> project() was not executed at all.
> I'm not sure here, but this is probably due to Flask prioritising the
> explicit route over the catch-all route.
>
> I changed the order around too - defined project() first - it doesn't
> matter, index() still got called on / and /index.
>
> So you can go ahead and define these routes in your app, index() will work
> as expected.
> Although be careful not to allow the creation of a project with the name of
> "index"...
>
> Greetings,
> Emanuil
>
>
>
> On 14 October 2013 18:05, Sasa Trifunovic <sasa.s.trifunovic@gmail.com>
> wrote:
>>
>> Hi,
>>
>> Nope, it was like that in the beginning, and that way it works but  i
>> have to omit 'projects' part of the URL.
>> It's photography related site so different kind of record in the near
>> future is not planned.
>>
>> BR
>> Sasa
>>
>> On Mon, Oct 14, 2013 at 6:54 PM, Emanuil Tolev <emanuil@cottagelabs.com>
>> wrote:
>> > Would it be OK for you to have a /projects/<key> route?
>> >
>> > @app.route('/projects/<path:projectkey>')
>> >
>> > I guess there's also the question "What if my app starts handling a
>> > different type of record in the future?" e.g. /users/<username> to view
>> > somebody's profile. Tying "/<something>" to mean "a specific project"
>> > would
>> > prevent you from handling different kinds of records.
>> >
>> > That's just an example of course, but apps will usually want to handle
>> > more
>> > than one kind of record at some point.
>> >
>> > Greetings,
>> > Emanuil
>> >
>> >
>> >
>> > On 14 October 2013 17:37, Sasa Trifunovic <sasa.s.trifunovic@gmail.com>
>> > wrote:
>> >>
>> >> I have URL related problem. I have index page and project page(on
>> >> which can be displayed one of many projects,depending on what
>> >> projectkey you pass as an argument). I want to have "pretty" urls so i
>> >> can have domainname.com/index and domainname.com/some_project_key
>> >> calling different view functions
>> >>
>> >> @app.route('/')
>> >> @app.route('/index')
>> >> def index():
>> >> pass
>> >>
>> >> @app.route('/<path:projectkey>')
>> >> def project(projectkey):
>> >> pass
>> >>
>> >> This doesn't work for me because if i try going to the index page it
>> >> will go through index function but before it returns template it will
>> >> also run project function ,in which it will run query on non existing
>> >> project. Is there some built in solution for this or some workaround
>> >> is needed? Any help i can get is much appreciated.
>> >
>> >
>
>

Re: [flask] Same URL pattern calling different view functions in Flask

From:
Leiser Fg
Date:
2013-10-15 @ 03:21
Just serve a favicon! 


import os.path 
from flask import Flask, send_from_directory 

app = Flask(__name__) 



@app.route('/favicon.ico') 
def favicon(): 
return send_from_directory(os.path.join(app.root_path, 'static'), 
'favicon.ico', mimetype='image/vnd.microsoft.icon') 

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


@app.route('/<path:projectkey>') 
def project(projectkey): 
print 'this is executing' 
return 'project ' + projectkey 

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




----- Mensaje original -----


Thanks for the help. Problem is with favicon.ico , browser is sending 
GET request to /favicon.ico so project(projectkey) is called with 
favicon.ico as an argument. 

BR 
Sasa 

On Mon, Oct 14, 2013 at 9:31 PM, Emanuil Tolev <emanuil@cottagelabs.com> wrote: 
> Trying to recreate your routes seems to actually work OK. 
> 
> I created a new virtualenv to play with Flask in, using 64-bit Python 2.7.4 
> . 
> I then did 
> pip install Flask 
> . 
> The latest Flask in pip seems to be 10.1 and installed the following 
> dependencies: 
> 
> Flask==0.10.1 
> Jinja2==2.7.1 
> MarkupSafe==0.18 
> Werkzeug==0.9.4 
> argparse==1.2.1 
> itsdangerous==0.23 
> wsgiref==0.1.2 
> 
> 
> So, with that environment, I ran a minimal example: 
> 
> from flask import Flask 
> app = Flask(__name__) 
> 
> 
> @app.route('/') 
> @app.route('/index') 
> def index(): 
> return 'index' 
> 
> 
> @app.route('/<path:projectkey>') 
> def project(projectkey): 
> print 'this is executing' 
> return 'project ' + projectkey 
> 
> if __name__ == '__main__': 
> app.run(debug=True) 
> 
> 
> These are the responses I got: 
> 
> $ curl http://localhost:5000/; echo 
> index 
> $ curl http://localhost:5000/index; echo 
> index 
> $ curl http://localhost:5000/aprojectkey; echo 
> project aprojectkey 
> # (and "this is executing" in the log) 
> 
> That is to say, going to /index only triggered the index() function - 
> project() was not executed at all. 
> I'm not sure here, but this is probably due to Flask prioritising the 
> explicit route over the catch-all route. 
> 
> I changed the order around too - defined project() first - it doesn't 
> matter, index() still got called on / and /index. 
> 
> So you can go ahead and define these routes in your app, index() will work 
> as expected. 
> Although be careful not to allow the creation of a project with the name of 
> "index"... 
> 
> Greetings, 
> Emanuil 
> 
> 
> 
> On 14 October 2013 18:05, Sasa Trifunovic <sasa.s.trifunovic@gmail.com> 
> wrote: 
>> 
>> Hi, 
>> 
>> Nope, it was like that in the beginning, and that way it works but i 
>> have to omit 'projects' part of the URL. 
>> It's photography related site so different kind of record in the near 
>> future is not planned. 
>> 
>> BR 
>> Sasa 
>> 
>> On Mon, Oct 14, 2013 at 6:54 PM, Emanuil Tolev <emanuil@cottagelabs.com> 
>> wrote: 
>> > Would it be OK for you to have a /projects/<key> route? 
>> > 
>> > @app.route('/projects/<path:projectkey>') 
>> > 
>> > I guess there's also the question "What if my app starts handling a 
>> > different type of record in the future?" e.g. /users/<username> to view 
>> > somebody's profile. Tying "/<something>" to mean "a specific project" 
>> > would 
>> > prevent you from handling different kinds of records. 
>> > 
>> > That's just an example of course, but apps will usually want to handle 
>> > more 
>> > than one kind of record at some point. 
>> > 
>> > Greetings, 
>> > Emanuil 
>> > 
>> > 
>> > 
>> > On 14 October 2013 17:37, Sasa Trifunovic <sasa.s.trifunovic@gmail.com> 
>> > wrote: 
>> >> 
>> >> I have URL related problem. I have index page and project page(on 
>> >> which can be displayed one of many projects,depending on what 
>> >> projectkey you pass as an argument). I want to have "pretty" urls so i 
>> >> can have domainname.com/index and domainname.com/some_project_key 
>> >> calling different view functions 
>> >> 
>> >> @app.route('/') 
>> >> @app.route('/index') 
>> >> def index(): 
>> >> pass 
>> >> 
>> >> @app.route('/<path:projectkey>') 
>> >> def project(projectkey): 
>> >> pass 
>> >> 
>> >> This doesn't work for me because if i try going to the index page it 
>> >> will go through index function but before it returns template it will 
>> >> also run project function ,in which it will run query on non existing 
>> >> project. Is there some built in solution for this or some workaround 
>> >> is needed? Any help i can get is much appreciated. 
>> > 
>> > 
> 
> 

________________________________________________________________________________________________

III Escuela Internacional de Invierno en la UCI del 17 al 28 de febrero 
del 2014. Ver www.uci.cu 



________________________________________________________________________________________________
III Escuela Internacional de Invierno en la UCI del 17 al 28 de febrero 
del 2014. Ver www.uci.cu--=_b20d4bdb-b36b-4637-91e2-aa6cf85a9209
Content-Type: text/html; charset=utf-8
Content-Transfer-Encoding: quoted-printable

<html><head><style type=3D'text/css'>p { margin: 0; }</style></head><body><=
div style=3D'font-family: arial,helvetica,sans-serif; font-size: 12pt; colo=
r: #000000'><font face=3D"arial, helvetica, sans-serif" size=3D"3">Just ser=
ve a favicon!</font><div><span style=3D"color: rgb(0, 0, 0); font-family: H=
elvetica, Arial, sans-serif; font-size: 12pt;"><br></span></div><div><font =
face=3D"Helvetica, Arial, sans-serif">import os.path</font></div><div><span=
 style=3D"color: rgb(0, 0, 0); font-family: Helvetica, Arial, sans-serif; f=
ont-size: 12pt;">from flask import Flask, </span><font face=3D"Helveti=
ca, Arial, sans-serif">send_from_directory</font></div><div style=3D"color:=
 rgb(0, 0, 0); font-family: arial, helvetica, sans-serif; font-size: 12pt;"=
><br style=3D"font-family: Helvetica, Arial, sans-serif;"><span style=3D"fo=
nt-family: Helvetica, Arial, sans-serif;"> app =3D Flask(__name__)</sp=
an><br style=3D"font-family: Helvetica, Arial, sans-serif;"><br style=3D"fo=
nt-family: Helvetica, Arial, sans-serif;"></div><div><div><font face=3D"ari=
al, helvetica, sans-serif">@app.route('/favicon.ico')</font></div><div><fon=
t face=3D"arial, helvetica, sans-serif">def favicon():</font></div><div><fo=
nt face=3D"arial, helvetica, sans-serif">    return send_from_dir=
ectory(os.path.join(app.root_path, 'static'),</font></div><div><font face=
=3D"arial, helvetica, sans-serif">           =
                     &nbs=
p;                   'favicon.=
ico', mimetype=3D'image/vnd.microsoft.icon')</font></div></div><div style=
=3D"color: rgb(0, 0, 0); font-family: arial, helvetica, sans-serif; font-si=
ze: 12pt;"><br style=3D"font-family: Helvetica, Arial, sans-serif;"><span s=
tyle=3D"font-family: Helvetica, Arial, sans-serif;"> @app.route('/')</=
span><br style=3D"font-family: Helvetica, Arial, sans-serif;"><span style=
=3D"font-family: Helvetica, Arial, sans-serif;"> @app.route('/index')<=
/span><br style=3D"font-family: Helvetica, Arial, sans-serif;"><span style=
=3D"font-family: Helvetica, Arial, sans-serif;"> def index():</span><b=
r style=3D"font-family: Helvetica, Arial, sans-serif;"><span style=3D"font-=
family: Helvetica, Arial, sans-serif;">     return 'index'</=
span><br style=3D"font-family: Helvetica, Arial, sans-serif;"><br style=3D"=
font-family: Helvetica, Arial, sans-serif;"><br style=3D"font-family: Helve=
tica, Arial, sans-serif;"><span style=3D"font-family: Helvetica, Arial, san=
s-serif;"> @app.route('/<path:projectkey>')</span><br style=3D"f=
ont-family: Helvetica, Arial, sans-serif;"><span style=3D"font-family: Helv=
etica, Arial, sans-serif;"> def project(projectkey):</span><br style=
=3D"font-family: Helvetica, Arial, sans-serif;"><span style=3D"font-family:=
 Helvetica, Arial, sans-serif;">     print 'this is executin=
g'</span><br style=3D"font-family: Helvetica, Arial, sans-serif;"><span sty=
le=3D"font-family: Helvetica, Arial, sans-serif;">     retur=
n 'project ' + projectkey</span><br style=3D"font-family: Helvetica, Arial,=
 sans-serif;"><br style=3D"font-family: Helvetica, Arial, sans-serif;"><spa=
n style=3D"font-family: Helvetica, Arial, sans-serif;"> if __name__ =
=3D=3D '__main__':</span><br style=3D"font-family: Helvetica, Arial, sans-s=
erif;"><span style=3D"font-family: Helvetica, Arial, sans-serif;">  &n=
bsp;  app.run(debug=3DTrue)</span><br style=3D"font-family: Helvetica,=
 Arial, sans-serif;"><br><div><br><br><hr id=3D"zwchr"><div style=3D"color:=
#000;font-weight:normal;font-style:normal;text-decoration:none;font-family:=
Helvetica,Arial,sans-serif;font-size:12pt;"><br>Thanks for the help. Proble=
m is with favicon.ico , browser is sending<br>GET request to /favicon.ico s=
o project(projectkey) is called with<br>favicon.ico as an argument.<br><br>=
BR<br>Sasa<br><br>On Mon, Oct 14, 2013 at 9:31 PM, Emanuil Tolev <emanui=
l@cottagelabs.com> wrote:<br>> Trying to recreate your routes seems t=
o actually work OK.<br>><br>> I created a new virtualenv to play with=
 Flask in, using 64-bit Python 2.7.4<br>> .<br>> I then did<br>> &=
nbsp;   pip install Flask<br>> .<br>> The latest Flask in pip se=
ems to be 10.1 and installed the following<br>> dependencies:<br>><br=
>> Flask=3D=3D0.10.1<br>> Jinja2=3D=3D2.7.1<br>> MarkupSafe=3D=3D0=
.18<br>> Werkzeug=3D=3D0.9.4<br>> argparse=3D=3D1.2.1<br>> itsdang=
erous=3D=3D0.23<br>> wsgiref=3D=3D0.1.2<br>><br>><br>> So, with=
 that environment, I ran a minimal example:<br>><br>> from flask impo=
rt Flask<br>> app =3D Flask(__name__)<br>><br>><br>> @app.route=
('/')<br>> @app.route('/index')<br>> def index():<br>>   &nbs=
p; return 'index'<br>><br>><br>> @app.route('/<path:projectkey&=
gt;')<br>> def project(projectkey):<br>>     print 'this is=
 executing'<br>>     return 'project ' + projectkey<br>><br=
>> if __name__ =3D=3D '__main__':<br>>     app.run(debug=
=3DTrue)<br>><br>><br>> These are the responses I got:<br>><br>=
> $ curl http://localhost:5000/; echo<br>> index<br>> $ curl http:=
//localhost:5000/index; echo<br>> index<br>> $ curl http://localhost:=
5000/aprojectkey; echo<br>> project aprojectkey<br>> # (and "this is =
executing" in the log)<br>><br>> That is to say, going to /index only=
 triggered the index() function -<br>> project() was not executed at all=
.<br>> I'm not sure here, but this is probably due to Flask prioritising=
 the<br>> explicit route over the catch-all route.<br>><br>> I cha=
nged the order around too - defined project() first - it doesn't<br>> ma=
tter, index() still got called on / and /index.<br>><br>> So you can =
go ahead and define these routes in your app, index() will work<br>> as =
expected.<br>> Although be careful not to allow the creation of a projec=
t with the name of<br>> "index"...<br>><br>> Greetings,<br>> Em=
anuil<br>><br>><br>><br>> On 14 October 2013 18:05, Sasa Trifun=
ovic <sasa.s.trifunovic@gmail.com><br>> wrote:<br>>><br>>=
> Hi,<br>>><br>>> Nope, it was like that in the beginning, a=
nd that way it works but  i<br>>> have to omit 'projects' part o=
f the URL.<br>>> It's photography related site so different kind of r=
ecord in the near<br>>> future is not planned.<br>>><br>>>=
; BR<br>>> Sasa<br>>><br>>> On Mon, Oct 14, 2013 at 6:54 =
PM, Emanuil Tolev <emanuil@cottagelabs.com><br>>> wrote:<br>>=
;> > Would it be OK for you to have a /projects/<key> route?<br=
>>> ><br>>> > @app.route('/projects/<path:projectkey&g=
t;')<br>>> ><br>>> > I guess there's also the question "W=
hat if my app starts handling a<br>>> > different type of record i=
n the future?" e.g. /users/<username> to view<br>>> > somebo=
dy's profile. Tying "/<something>" to mean "a specific project"<br>&g=
t;> > would<br>>> > prevent you from handling different kind=
s of records.<br>>> ><br>>> > That's just an example of c=
ourse, but apps will usually want to handle<br>>> > more<br>>&g=
t; > than one kind of record at some point.<br>>> ><br>>>=
 > Greetings,<br>>> > Emanuil<br>>> ><br>>> >=
<br>>> ><br>>> > On 14 October 2013 17:37, Sasa Trifunovi=
c <sasa.s.trifunovic@gmail.com><br>>> > wrote:<br>>> &=
gt;><br>>> >> I have URL related problem. I have index page =
and project page(on<br>>> >> which can be displayed one of many=
 projects,depending on what<br>>> >> projectkey you pass as an =
argument). I want to have "pretty" urls so i<br>>> >> can have =
domainname.com/index and domainname.com/some_project_key<br>>> >&g=
t; calling different view functions<br>>> >><br>>> >&g=
t; @app.route('/')<br>>> >> @app.route('/index')<br>>> &g=
t;> def index():<br>>> >> pass<br>>> >><br>>&=
gt; >> @app.route('/<path:projectkey>')<br>>> >> de=
f project(projectkey):<br>>> >> pass<br>>> >><br>&g=
t;> >> This doesn't work for me because if i try going to the inde=
x page it<br>>> >> will go through index function but before it=
 returns template it will<br>>> >> also run project function ,i=
n which it will run query on non existing<br>>> >> project. Is =
there some built in solution for this or some workaround<br>>> >&g=
t; is needed? Any help i can get is much appreciated.<br>>> ><br>&=
gt;> ><br>><br>><br>___________________________________________=
_____________________________________________________<br>III Escuela Intern=
acional de Invierno en la UCI del 17 al 28 de febrero del 2014. Ver www.uci=
.cu                     &=
nbsp;                    =
                     &nbs=
p;                    <br=
></div><br></div></div></div>
<br>=
<html>=0A<body>=0A<hr align=3D"LEFT" size=3D"1" width=3D"630" 
color=3D"Black" noshade>=0A<p>III Escuela Internacional de Invierno en la 
UCI del 17 al 28 de febrero del 2014. Ver <a href=3D"http://www.uci.cu/"> 
www.uci.cu </a>=0A<!--<img 
src=3D"http://universidad.uci.cu/cinta.png"/>-->=0A</body>=0A</html>=0A
<br>=
</body></html>