import

G

Gert Cuykens

I would like to lauch a server from outside the side package directory
how do i specify a path with import

#/home/gert/Desktop/www/db/py/start-server.py
import cherrypy

class HelloWorld:
def index(self):
return #external htm file Hello world!
index.exposed = True

if __name__ == '__main__': # ??? dont know what is this for
import os.path
conf = os.path.join(os.path.dirname(__file__), 'conf-server.py')
cherrypy.config.update(conf)
cherrypy.quickstart(HelloWorld())
else:
cherrypy.tree.mount(HelloWorld()) # ??? dont know what is this for

#/home/gert/Desktop/www/db/py/conf-server.py
[global]

server.socket_port = 8080

server.thread_pool = 10
 
B

Bruno Desthuilliers

Gert Cuykens a écrit :
I would like to lauch a server from outside the side package directory
how do i specify a path with import
http://docs.python.org/tut/node8.html#SECTION008110000000000000000

(snip)


if __name__ == '__main__': # ??? dont know what is this for

When a module is used as a program (ie python myprog.py), the
module-level magic variable '__name__' is set to main. If the module is
imported by another one, this variable is set to the name of the
module. This allow a module to have different behaviours according to
how it is used.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,819
Latest member
masterdaster

Latest Threads

Top