Saswati De
2015-08-04 00:18:32 UTC
Hello Everyone,
I have around 100 journal articles. Each journal article is represented as
an HTML page. A journal's HTML page, its css file and the figures that are
part of the journal are located within its folder. In other words, each
html file refers to it's own css file and corresponding image files. And I
have created the following folder structure ( | represents a folder, --
represents a file):
-- app.py
|views
-- Disp_Res.tpl
-- UI.tpl
|static
|articles
|PMC45677
--PMC45677.html
--jats-preview.css
--fig1_45677.jpg
--fig2_45677.jpg
|PMC23456
--PMC23456.html
--jats-preview.css
--fig1_23456.jpg
--fig2_23456.jpg
In my template file, I have the below:
<a href="/articles/PMC{{myPMCID}}" target="_blank">PMC{{myPMCID}} </a>
I have the following code within my app.py:
@app.get('/articles/<pmc:re:PMC[0-9]*>')def html_article(pmc):
global pmcno
pmcno = pmc;
pmc_article = pmcno + ".html"; print pmc_article
rootdir = os.path.join('static/articles', pmcno)
print "html_article", rootdir # This statement displays the right dir
return static_file(pmc_article, root=rootdir)
@app.get('/<filename:re:.*\.css>')def stylesheets(filename):
rootdir = os.path.join('static/articles', pmcno)
print "stylesheets", rootdir # This statement does NOT display
return static_file(filename, root=rootdir)
@app.get('/<filename:re:.*\.(jpg|png|gif|ico)>')def images(filename):
rootdir = os.path.join('static/articles', pmcno)
print "images", rootdir # This statement does NOT display
return static_file(filename, root=rootdir)
The journal html files (for eg: PMC45677.html) refer to jpg and css files in the following way:
<head>
<link rel="stylesheet" type="text/css" href="jats-preview.css">
</head>
<div><img alt="JCB_201310071_Fig1" src="fig1_45677.jpg"></div>
...
Needless to say, this doesn't work. When I run app.py, it gives the error:
"Sorry, the requested URL 'http://localhost:8080/articles/PMC45677' caused
an error: File does not exist."
I have been stuck on this for hours... :-(
Any idea what I am doing wrong? Or do any of you have a better idea of
achieving what I am aiming at? Please do let me know. Any help will be
highly appreciated!
Thanks in advance.
Regards,
Saswati
--
I have around 100 journal articles. Each journal article is represented as
an HTML page. A journal's HTML page, its css file and the figures that are
part of the journal are located within its folder. In other words, each
html file refers to it's own css file and corresponding image files. And I
have created the following folder structure ( | represents a folder, --
represents a file):
-- app.py
|views
-- Disp_Res.tpl
-- UI.tpl
|static
|articles
|PMC45677
--PMC45677.html
--jats-preview.css
--fig1_45677.jpg
--fig2_45677.jpg
|PMC23456
--PMC23456.html
--jats-preview.css
--fig1_23456.jpg
--fig2_23456.jpg
In my template file, I have the below:
<a href="/articles/PMC{{myPMCID}}" target="_blank">PMC{{myPMCID}} </a>
I have the following code within my app.py:
@app.get('/articles/<pmc:re:PMC[0-9]*>')def html_article(pmc):
global pmcno
pmcno = pmc;
pmc_article = pmcno + ".html"; print pmc_article
rootdir = os.path.join('static/articles', pmcno)
print "html_article", rootdir # This statement displays the right dir
return static_file(pmc_article, root=rootdir)
@app.get('/<filename:re:.*\.css>')def stylesheets(filename):
rootdir = os.path.join('static/articles', pmcno)
print "stylesheets", rootdir # This statement does NOT display
return static_file(filename, root=rootdir)
@app.get('/<filename:re:.*\.(jpg|png|gif|ico)>')def images(filename):
rootdir = os.path.join('static/articles', pmcno)
print "images", rootdir # This statement does NOT display
return static_file(filename, root=rootdir)
The journal html files (for eg: PMC45677.html) refer to jpg and css files in the following way:
<head>
<link rel="stylesheet" type="text/css" href="jats-preview.css">
</head>
<div><img alt="JCB_201310071_Fig1" src="fig1_45677.jpg"></div>
...
Needless to say, this doesn't work. When I run app.py, it gives the error:
"Sorry, the requested URL 'http://localhost:8080/articles/PMC45677' caused
an error: File does not exist."
I have been stuck on this for hours... :-(
Any idea what I am doing wrong? Or do any of you have a better idea of
achieving what I am aiming at? Please do let me know. Any help will be
highly appreciated!
Thanks in advance.
Regards,
Saswati
--
--
You are member of the "bottlepy" group at google groups.
See http://groups.google.de/group/bottlepy for mailing list options.
See http://bottlepy.org/ for news and documentation.
---
You received this message because you are subscribed to the Google Groups "bottlepy" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bottlepy+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
You are member of the "bottlepy" group at google groups.
See http://groups.google.de/group/bottlepy for mailing list options.
See http://bottlepy.org/ for news and documentation.
---
You received this message because you are subscribed to the Google Groups "bottlepy" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bottlepy+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.