@@ -202,3 +202,48 @@ npm test
202202npm run lint
203203```
204204
205+ ## To test protocols and schemas locally
206+
207+ Run this cors server script in the root directory of your reproschema. For
208+ example, if you clone the demo-protocol, run the script inside the cloned
209+ directory. This script will serve the tree locally.
210+
211+ ``` python
212+ # !/usr/bin/env python3
213+
214+ # It's python3 -m http.server PORT for a CORS world
215+
216+ from http.server import HTTPServer, SimpleHTTPRequestHandler
217+ import sys
218+
219+
220+ class CORSRequestHandler (SimpleHTTPRequestHandler ):
221+
222+ def end_headers (self ):
223+ self .send_header(' Access-Control-Allow-Origin' , ' *' )
224+ self .send_header(' Access-Control-Allow-Methods' , ' *' )
225+ self .send_header(' Access-Control-Allow-Headers' , ' *' )
226+ self .send_header(' Cache-Control' , ' no-store, no-cache, must-revalidate' )
227+ return super (CORSRequestHandler, self ).end_headers()
228+
229+ def do_OPTIONS (self ):
230+ self .send_response(200 )
231+ self .end_headers()
232+
233+ host = sys.argv[1 ] if len (sys.argv) > 2 else ' 0.0.0.0'
234+ port = int (sys.argv[len (sys.argv)- 1 ]) if len (sys.argv) > 1 else 8000
235+
236+ print (" Listening on {} :{} " .format(host, port))
237+ httpd = HTTPServer((host, port), CORSRequestHandler)
238+ httpd.serve_forever()
239+ ```
240+
241+ Change config.js in this ui repo to point to your local schema. For example,
242+ if you cloned the demo protocol it would look like this:
243+
244+ ```
245+ githubSrc: 'http://localhost:8000/DemoProtocol/DemoProtocol_schema',
246+ ```
247+
248+
249+
0 commit comments