热门问题
时间线
聊天
视角

Quixote (web框架)

来自维基百科,自由的百科全书

Remove ads

Quixote是一個使用Python開發web應用軟件框架。Quixote是「基於了簡單的、靈活的設計,使得可以快速的書寫應用,並受益於廣泛的可獲得的第三方Python模組。」[4]

快速預覽 開發者, 首次發布 ...

Quixote應用典型的是個Python包,即組織入一個單一的目錄樹中的一組模組。Quixote接着對映一個URL至這個Python包內的一個函數方法;接着用這個HTTP請求的內容來呼叫這個函數,並將結果返回給客戶端

Remove ads

演示代碼

最小的Quixote演示程式。在安裝了quixote包之後,可以如下這樣執行它:$ python demo/mini_demo.py。這個伺服器預設的監聽localhost:8080。除錯和錯誤輸出會傳送到終端。

from quixote.publish import Publisher
from quixote.directory import Directory, export

class RootDirectory(Directory):
    @export(name='')
    def index(self):
        return '''<html>
                    <body>Welcome to the Quixote demo.  Here is a
                    <a href="hello">link</a>.
                    </body>
                  </html>
               '''
    @export
    def hello(self):
        return '<html><body>Hello world!</body></html>'

def create_publisher():
    return Publisher(RootDirectory(),
                     display_exceptions='plain')

if __name__ == '__main__':
    from quixote.server.simple_server import run
    print('creating demo listening on http://localhost:8080/')
    run(create_publisher, host='localhost', port=8080)
Remove ads

參見

參照

外部連結

Loading content...
Loading related searches...

Wikiwand - on

Seamless Wikipedia browsing. On steroids.

Remove ads