我的代码背后的想法是在运行的每个html文件和wsgi_mod文件的数据末尾添加一个计数器: 计数器只是根据先前的计算结果将该值相加。 问题是每次我尝试加载
superhost.gr/clientele
or
superhost.gr/download
我已经在httpd.conf中为这两个python应用程序提供了一个开放的mod_wsgi过程 因此,每次app.py试图通过请求对象获取另一个wsgi应用程序的响应时,它都会一直等待很长时间,直到i ctrl-c
如何通过请求方法打开wsgi应用程序并以html数据的形式返回它
=======================================================================================
@app.route( '/' )
@app.route( '/<page>' )
def index( page='index.html' ):
# read environment
pdata = ''
if page == 'index.html' or page in ('clientele', 'downloads'):
init()
database( page )
cur.execute( '''SELECT hits FROM pages WHERE url = %s''', page )
pagehit = cur.fetchone()[0]
# pick random line from the quote text file & random mp3 from the the music folder
quote = random.choice( list( open( '/home/nikos/public_html/data/private/quotes.txt', encoding='utf-8' ) ) )
music = random.choice( os.listdir( '/home/nikos/wsgi/static/mp3/' ) )
# add counter to html template and start rendering
counter = '''<table bgcolor=black bordercolor=orangered>
<td><font size=3 color=lime> Αριθμός Επισκεπτών: </font></td> <td><a href="%s"><font size=3 color=plum> %s </font></a></td>
</table>
''' % ( url_for('log', page=page), pagehit )
if page in ('clientele', 'downloads'):
try:
r = requests.get( 'http://superhost.gr/' + page )
if r.ok:
pdata = r.text + counter
except Exception:
sys.exit(0)
elif page.endswith( '.html' ):
pdata = render_template( page, quote=quote, music=music, page=page, pagehit=pagehit ) + counter
return pdata
目前没有回答
相关问题 更多 >
编程相关推荐