Help | Site Map
Connecting Tech Pros Worldwide
 
 
LinkBack Thread Tools
  #1  
Old December 18th, 2006, 12:15 AM
Gert Cuykens
Guest
 
Posts: n/a
Default import

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
  #2  
Old December 18th, 2006, 10:55 AM
Bruno Desthuilliers
Guest
 
Posts: n/a
Default Re: import

Gert Cuykens a écrit :
Quote:
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.htm...00000000000000

(snip)

Quote:
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.
 

Bookmarks

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over network members.
Post your question now . . .
It's fast and it's free

Popular Articles