mirror of
https://github.com/odoo/owl.git
synced 2025-10-06 19:59:41 +07:00
b8b5190bc6
Currently, some of the things on the playground must be changed directly on the master branch while other things require checking out the gh-pages branch and making the modifications there. Even when changes need to be made on the master branch, all changes that are not direcly in owl itself need to be copied by hand to the gh-pages branch. This commit moves all files that exist on the gh-pages branch to the master branch in the docs folder, this change will require configuring the github page to use the docs folder instead of a separate branch, but will make maintenance of the github page and playground easier going forward.
47 lines
1.5 KiB
Python
47 lines
1.5 KiB
Python
#!/usr/bin/env python3
|
|
|
|
import threading
|
|
import time
|
|
from http.server import SimpleHTTPRequestHandler, HTTPServer
|
|
|
|
HOST = '127.0.0.1'
|
|
PORT = 8000
|
|
URL = 'http://{0}:{1}/docs/playground'.format(HOST, PORT)
|
|
|
|
|
|
# We define our own handler here to remap owl.js GET requests to the Owl build
|
|
# in dist/. This is useful for the benchmarks and playground applications.
|
|
# With this, we can simply copy the playground folder as is in the gh-page when
|
|
# we want to update the playground.
|
|
class OWLHandler(SimpleHTTPRequestHandler):
|
|
def do_GET(self):
|
|
if self.path == '/docs/owl.js' or self.path == '/docs/playground/owl.js':
|
|
self.path = '/dist/owl.es.js'
|
|
return SimpleHTTPRequestHandler.do_GET(self)
|
|
|
|
def end_headers(self):
|
|
self.disable_cache_headers()
|
|
SimpleHTTPRequestHandler.end_headers(self)
|
|
|
|
def disable_cache_headers(self):
|
|
self.send_header("Cache-Control", "no-cache, no-store, must-revalidate")
|
|
self.send_header("Pragma", "no-cache")
|
|
self.send_header("Expires", "0")
|
|
|
|
|
|
OWLHandler.extensions_map['.js'] = 'application/javascript'
|
|
|
|
if __name__ == "__main__":
|
|
print("Owl Tools")
|
|
print("---------")
|
|
print("Server running on: {}".format(URL))
|
|
httpd = HTTPServer((HOST, PORT), OWLHandler)
|
|
threading.Thread(target=httpd.serve_forever, daemon=True).start()
|
|
|
|
while True:
|
|
try:
|
|
time.sleep(1)
|
|
except KeyboardInterrupt:
|
|
httpd.server_close()
|
|
quit(0)
|