mirror of
https://github.com/odoo/owl.git
synced 2025-10-06 19:59:41 +07:00
9475de4d18
The playground hasn't been touched for a while and a few things were broken before this commit: - Exporting as a standalone web application was broken because it still attempted to load the templates like it was done in owl 1 - Resizing the editor tabs still tried to use `this.trigger` While fixing the export feature, the files needed by the app were factored out of hardcoded strings and into real files, as this makes it easier to maintain, since these files get syntax highlighting. The samples received the same treatment: there is now a `samples` folder containing all the samples, it also contains a jsconfig, giving autocompletion on owl functions while editing the files, and allowing the owl import to look how it would when using owl as a node_module. In the browser, this import is translated to the relative path of the owl module using an import map.
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}/tools/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 == '/tools/owl.js' or self.path == '/tools/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)
|