/ interactive_tutorials / duffing_islands
Sign in
interactive_tutorials / duffing_islands
duffing_islands / scripts / serve.py
22 lines · 786 BCodeBlameHistory
574ea55Tracks, SoundFonts, sessions, recording and MIDIJeremy Magland 1# The dev server: app/ at http://127.0.0.1:8002, with caching off, so a
2# reload always gets the current modules (a browser mixing cached old ones
3# with new ones breaks the page).
4import functools
5import http.server
6import os
8ROOT = os.path.join(os.path.dirname(os.path.abspath(__file__)), '..', 'app')
11class NoCache(http.server.SimpleHTTPRequestHandler):
12 def end_headers(self):
13 self.send_header('Cache-Control', 'no-store')
14 super().end_headers()
17if __name__ == '__main__':
18 handler = functools.partial(NoCache, directory=ROOT)
19 port = int(os.environ.get('PORT', 8002))
20 with http.server.ThreadingHTTPServer(('127.0.0.1', port), handler) as server:
21 print(f'Serving app/ at http://127.0.0.1:{port} (no caching)')
22 server.serve_forever()
↑↓ move↵openescclose