Skip to content
This repository was archived by the owner on Sep 28, 2022. It is now read-only.
This repository was archived by the owner on Sep 28, 2022. It is now read-only.

Pleases provide guidance on how to embed scriptedforms in iframe #300

@mrpeterlee

Description

@mrpeterlee

Hi Team,

Many thanks for the work and I found scriptedforms particular useful in presenting outputs. I'd greatly appreciate any advices on how to embed the local instance of scriptedforms in a webpage so it could be presented to my colleagues.

I have been running into "Content Security Violation" error, although using the same setup I have no problems embedding a local Jupyter Notebook instance. The following is my configuration (so far NOT working), once again, grateful to any comments.

Flask app to embed the output of scriptedforms via iframe

Modified scriptedforms.py

    def start(self):
    ┆   load_jupyter_server_extension(self)
    ┆   # Add remote access# self.config_file = u"/home/d594400/.jupyter/jupyter_notebook_config.py"  # Doesn't work# self.port = 9999  # CANNOT change port# self.ip = u"10.0.2.15"  # IP must be localhost, CANNOT change IPself.allow_remote_access = Trueself.token = ""self.password = ""self.tornado_settings = {
    ┆   ┆   "headers": {
    ┆   ┆   ┆   "Content-Security-Policy": "frame-ancestors self http://localhost:8888 http://localhost:60010 http://127.0.0.1:8888 http://127.0.0.1:60010; report-uri /api/security/csp-report"
    ┆   } }
    ┆   super(ScriptedForms, self).start()

flask app

from flask import Flask
app = Flask(__name__)

@app.route('/')
def homepage():
    return """
    <h1>Hello world!</h1>
    <iframe id="nb-iframe" src="http://localhost:8888/scriptedforms/use/scripted.md" style="width:800px;height:600px;"></iframe> 
    <iframe id="nb-iframe" src="http://localhost:8888" style="width:800px;height:600px;"></iframe> 
    """
if __name__ == '__main__':
    app.run(host="0.0.0.0", port=60010, debug=True, use_reloader=True)

Then ran into error while visiting the local flask page:

[W 10:32:02.140 ScriptedForms] Content security violation:
{"csp-report":{"document-uri":"http://localhost:8888/scriptedforms/use/scripted.md?","referrer":","violated-directive":"frame-ancestors","effective-directive":"frame-ancestors","original-policy":"frame-ancestors
'self'; report-uri /api/security/csp-report","disposition":"enforce","blocked-uri":"http://localhost:8888/scriptedforms/use/scripted.md?","status-code":0,"script-sample":""}}

Thanks and regards,

Peter

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions