[python] mini web server
Petr Vanek
vanous na penguin.cz
Středa Únor 12 03:27:20 CET 2003
javorove listy se opet hlasi ke slovu ;-)
v emailove adrese nepouziva diakritiku, tak nas lehce rozeznate ;-),
krome toho javoru, of course...a ted proc pisu:
toz chlapi, cozpak nikdo nevi, jak toto udelat? oni, takove kapacity? ;-)
:
On Sun, Feb 09, 2003 at 08:30:29PM +0100, Petr Vanek wrote:
> On Mon, Feb 03, 2003 at 09:12:01PM +0100, Michal Molhanec wrote:
> > On Mon, 3 Feb 2003 20:47:26 +0100 Petr Vanek <vanous na penguin.cz> wrote:
> > jiste viz dokumentace - moduly: SimpleHTTPServer, CGIHTTPServer,
> > BaseHTTPServer, SocketServer atd. dle libosti
>
>
> diky vsem, uz mi to beha, jeste mam jeden dotaz:
> potrebuji spustit z jednoho scriptu dva servery (jeden httpd, druhy pro
> sql server), nicmene po spusteni jednoho se na ten druhy uz nedostane
> rada...musim pouzit fork (popr. popen), nebo to jde i jinak? nechci
> spoustet dva scripty...
>
> prikladam onen proklad:
> PORT = 2222
> #DB = "test"
> DB = "books"
> #DBDIR = "/home/vanous/htbin/db"
> DBDIR = "/home/dokumenty/python/bookshelve/bookdb"
> PW = "admin"
> STARTUP = "servers"
> doc_root = ('/home/vanous/htbin/')
>
> import sys, socket
> from gadfly.server import Server, Policy
> from gadfly.client import gfclient
> import BaseHTTPServer, SimpleHTTPServer, CGIHTTPServer
> import os
>
> def run(HandlerClass = CGIHTTPServer.CGIHTTPRequestHandler, ServerClass = BaseHTTPServer.HTTPServer):
> server_address=('',7000)
> httpd=ServerClass(server_address, HandlerClass)
> os.chdir(doc_root)
> httpd.serve_forever()
>
> def main():
> machine = 'localhost' #socket.gethostname()
> port = PORT
> print "attempting to start the server"
> print "making a server on", PORT, DB, DBDIR, PW, STARTUP
> S = Server(PORT, DB, DBDIR, PW, STARTUP)
> print "initializing the server"
> S.init()
> print "starting the server", S.connection
> S.start()
>
>
> def startup(admin_policy, connection, Server_instance):
> print
> # admin_policy["dumpwork"] = "select * from work"
> # test1 = Policy("test1", "test1", connection, queries=0)
> # test = Policy("test", "test", connection, queries=0)
> # test1["qlike"] = "select * from likes where drinker=?"
> # test["updatenan"] = """
> # update likes
> # set beer=?, perday=?
> # where drinker='nan'
> # """
> # test["getnan"] = """
> # select * from likes where drinker='nan'
> # """
> # from CGIHTTPServer import test
> # test()
>
>
> if __name__=="__main__":
> main()
--
bye
Vanous
-------------------------------------------------
Petr Vanek ..... ./\. ....
Debian GNU Linux .. _|\| |/|_ ..
vanous na penguin.cz .. \ /...
http://www.penguin.cz/~vanous ... >______< ...
Angus, Ontario, CANADA ...... / .......
-------------------------------------------------
Registered linux user #217487
------------- další část ---------------
A non-text attachment was scrubbed...
Name: [žádný popis není k dispozici]
Type: application/pgp-signature
Size: 232 bytes
Desc: [žádný popis není k dispozici]
URL: <http://www.py.cz/pipermail/python/attachments/20030212/5b94962b/attachment.asc>
Další informace o konferenci Python