mirror of
https://github.com/odoo/owl.git
synced 2025-10-06 19:59:41 +07:00
[IMP] extras: update server to python3, disable cache
This commit is contained in:
committed by
Géry Debongnie
parent
d22219f084
commit
5842ed51b0
+18
-12
@@ -39,26 +39,32 @@ const DEFAULT_HTML = `<!DOCTYPE html>
|
|||||||
</html>
|
</html>
|
||||||
`;
|
`;
|
||||||
|
|
||||||
const APP_PY = `import sys
|
const APP_PY = `#!/usr/bin/env python3
|
||||||
import thread
|
|
||||||
import webbrowser
|
import threading
|
||||||
import time
|
import time
|
||||||
|
|
||||||
import BaseHTTPServer, SimpleHTTPServer
|
from http.server import SimpleHTTPRequestHandler, HTTPServer
|
||||||
|
|
||||||
def start_server():
|
def start_server():
|
||||||
httpd = BaseHTTPServer.HTTPServer(('127.0.0.1', 3600), SimpleHTTPServer.SimpleHTTPRequestHandler)
|
SimpleHTTPRequestHandler.extensions_map['.js'] = 'application/javascript'
|
||||||
|
httpd = HTTPServer(('0.0.0.0', 3600), SimpleHTTPRequestHandler)
|
||||||
httpd.serve_forever()
|
httpd.serve_forever()
|
||||||
|
|
||||||
thread.start_new_thread(start_server,())
|
|
||||||
url = 'http://127.0.0.1:3600'
|
url = 'http://127.0.0.1:3600'
|
||||||
webbrowser.open_new(url)
|
|
||||||
|
|
||||||
while True:
|
if __name__ == "__main__":
|
||||||
try:
|
print("Owl Application")
|
||||||
time.sleep(1)
|
print("---------------")
|
||||||
except KeyboardInterrupt:
|
print("Server running on: {}".format(url))
|
||||||
sys.exit(0)
|
threading.Thread(target=start_server, daemon=True).start()
|
||||||
|
|
||||||
|
while True:
|
||||||
|
try:
|
||||||
|
time.sleep(1)
|
||||||
|
except KeyboardInterrupt:
|
||||||
|
httpd.server_close()
|
||||||
|
quit(0)
|
||||||
`;
|
`;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
+20
-15
@@ -1,10 +1,8 @@
|
|||||||
import sys
|
#!/usr/bin/env python3
|
||||||
import thread
|
|
||||||
import webbrowser
|
|
||||||
import time
|
|
||||||
|
|
||||||
import BaseHTTPServer
|
import threading
|
||||||
import SimpleHTTPServer
|
import time
|
||||||
|
from http.server import SimpleHTTPRequestHandler, HTTPServer
|
||||||
|
|
||||||
HOST = '127.0.0.1'
|
HOST = '127.0.0.1'
|
||||||
PORT = 8000
|
PORT = 8000
|
||||||
@@ -15,27 +13,34 @@ URL = 'http://{0}:{1}/extras'.format(HOST, PORT)
|
|||||||
# in dist/. This is useful for the benchmarks and playground applications.
|
# 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
|
# With this, we can simply copy the playground folder as is in the gh-page when
|
||||||
# we want to update the playground.
|
# we want to update the playground.
|
||||||
class OWLHandler(SimpleHTTPServer.SimpleHTTPRequestHandler):
|
class OWLHandler(SimpleHTTPRequestHandler):
|
||||||
def do_GET(self):
|
def do_GET(self):
|
||||||
if self.path == '/extras/owl.js':
|
if self.path == '/extras/owl.js':
|
||||||
self.path = '/dist/owl.js'
|
self.path = '/dist/owl.js'
|
||||||
return SimpleHTTPServer.SimpleHTTPRequestHandler.do_GET(self)
|
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")
|
||||||
|
|
||||||
|
|
||||||
def start_server():
|
OWLHandler.extensions_map['.js'] = 'application/javascript'
|
||||||
httpd = BaseHTTPServer.HTTPServer((HOST, PORT), OWLHandler)
|
|
||||||
httpd.serve_forever()
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
print("Owl Extras")
|
print("Owl Extras")
|
||||||
print("----------")
|
print("----------")
|
||||||
print("Server running on: {}".format(URL))
|
print("Server running on: {}".format(URL))
|
||||||
thread.start_new_thread(start_server, ())
|
httpd = HTTPServer((HOST, PORT), OWLHandler)
|
||||||
webbrowser.open_new(URL)
|
threading.Thread(target=httpd.serve_forever, daemon=True).start()
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
try:
|
try:
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
sys.exit(0)
|
httpd.server_close()
|
||||||
|
quit(0)
|
||||||
|
|||||||
+1
-1
@@ -10,7 +10,7 @@
|
|||||||
"minify": "uglifyjs dist/owl.js -o dist/owl.min.js --compress --mangle",
|
"minify": "uglifyjs dist/owl.js -o dist/owl.min.js --compress --mangle",
|
||||||
"test": "jest",
|
"test": "jest",
|
||||||
"test:watch": "jest --watch",
|
"test:watch": "jest --watch",
|
||||||
"extras:serve": "python extras/server.py",
|
"extras:serve": "python3 extras/server.py || python extras/server.py",
|
||||||
"extras": "npm run build && npm run extras:serve",
|
"extras": "npm run build && npm run extras:serve",
|
||||||
"extras:watch": "npm-run-all --parallel extras:serve \"build:* -- --watch\""
|
"extras:watch": "npm-run-all --parallel extras:serve \"build:* -- --watch\""
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user