我有一个用python和web.py编写的web服务器。 我想让它成为一个守护进程。所以有一个Linux(Debian)操作系统。 我写过一段代码。所以现在这个Web服务器作为守护进程启动,我可以在进程列表中看到它,并在我的浏览器中访问主页面。Web.py无法找到文件
我使用了web.py模块,并且在这个模块中有一个渲染技术。这项技术使用html模板来创建一个网页(与python混合的html代码)。在这个模板中,我使用标准的html代码来添加css样式和图片。包含这些内容的文件夹放置在守护程序运行文件的位置。
所以我的守护进程加载这个模板。但没有CSS或图像。我已经检查过模板代码的执行情况(输入一些文本字符串) - 一切都没问题。
所以有一个问题:为什么这个HTML不能达到其他内容,以及如何修复?
一个重要的事情:以前那只是网络服务器(不是守护进程)和非守护进程版本(我保留一个副本)很好!我启动守护进程时出现所有问题。
希望你的帮助!
有一些部分代码:
#Daemon start file
class Hive(Daemon):
def run(self):
app = web.application(urls, globals())
app.run()
if __name__ == "__main__":
daemon = Hive('/tmp/daemon-example.pid')
if len(sys.argv) == 2:
if 'start' == sys.argv[1]:
sys.argv[1] = '8080'
daemon.start()
elif 'stop' == sys.argv[1]:
daemon.stop()
elif 'restart' == sys.argv[1]:
daemon.restart()
else:
print "Unknown command"
sys.exit(2)
sys.exit(0)
else:
print "usage: %s start|stop|restart" % sys.argv[0]
sys.exit(2)
--------------------------------------------------------
#home.html - template that realizes a part of main page and loads some
#picture. I've checked the "if" operator (that activates the <img> tag) - server
#executes it. On my page I see a place for picture (standard form when
#page cannot find the picture to download).
$def with (clients)
<!-- отображение данных о клиентах в базе: ip-адрес, состояние, привилегии
-->
<style type='text/css'>
.client { height: 40px; }
.client_current { border-left: 4px solid lightgreen; }
</style>
<!--<div><span class='glyphicon glyphicon-arrow-down'
style='margin-right: 10px;'></span><a href='#' class='_sh'
data-active='1' data-remote='.online'>Online</a></div>-->
<div style="min-height: 100px;">
<div>Online</div>
<div class='online'>
$code:
offline = False
$for client in clients:
$if not offline and not client.online:
$code:
offline = True
</div><div>Offline</div><div class='offline'>
$if client.admin:
<div class='client client-admin' style='clear: both; padding: 4px;'>
$else:
<div class='client' style='clear: both; padding: 4px;'>
<a href='#client$client.id' onclick='return activateClient(this);' id='client$client.id' class='client_item'>
<div class='img' style='float: left;'>
$if client.icon:
<img src='/powerhive-0.3.beta/static/img/wait.png' />
$else:
<img src='/powerhive-0.3.beta/static/img/wait.png' />
</div>
<div style='float: left; font-size: 10px; margin: 2px;'>
<div style='font-weight: bold; font-size: 11px;'>$client.ip</div>
$client.info
</div>
</a>
</div>
</div>
</div>