Skip to content

Instantly share code, notes, and snippets.

@tonatos
Last active August 24, 2018 11:05
Show Gist options
  • Save tonatos/0443b03debad512f8bd2b5a153b384cc to your computer and use it in GitHub Desktop.
Save tonatos/0443b03debad512f8bd2b5a153b384cc to your computer and use it in GitHub Desktop.
from flask import Flask, render_template
from lti import ToolConfig, ToolConsumer

app = Flask(__name__)

@app.route('/')
def index():
    consumer = ToolConsumer(
        consumer_key='jetstyle-key',
        consumer_secret='jetstyle-secret',
        launch_url='https://stepik.org/lti/',
        params={
            'lti_message_type': 'basic-lti-launch-request',
            'lti_version': 'LTI-1.1',
            'resource_link_id': 'https://0.0.0.0:5000/my-courses/25665/',
            'lis_person_name_full': 'Semyachkin Vitaly',
            'lis_person_contact_email_primary': 'tonatossn@gmail.com',
            'custom_course': 25665
        }
    )

    return render_template(
        'index.html', 
        launch_data=consumer.generate_launch_data(),
        launch_url=consumer.launch_url
    )

if __name__ == '__main__':
    app.run(host='0.0.0.0', port=5000, debug=True)
    <form action="https://stepik.org/lti/"
          name="ltiLaunchForm"
          id="ltiLaunchForm"
          method="POST"
          encType="application/x-www-form-urlencoded">
        <input type="hidden" name="lti_message_type" value="basic-lti-launch-request"/>
        <input type="hidden" name="lti_version" value="LTI-1.1"/>
        <input type="hidden" name="resource_link_id" value="https://0.0.0.0:5000/my-courses/25665/"/>
        <input type="hidden" name="lis_person_name_full" value="Semyachkin Vitaly"/>
        <input type="hidden" name="lis_person_contact_email_primary" value="tonatossn@gmail.com"/>
        <input type="hidden" name="custom_course" value="25665"/>
        <input type="hidden" name="oauth_nonce" value="92961655005547825101535108678"/>
        <input type="hidden" name="oauth_timestamp" value="1535108678"/>
        <input type="hidden" name="oauth_version" value="1.0"/>
        <input type="hidden" name="oauth_signature_method" value="HMAC-SHA1"/>
        <input type="hidden" name="oauth_consumer_key" value="jetstyle-key"/>
        <input type="hidden" name="oauth_signature" value="+UKyBlgGkXhinzNwxAXa9Xd/Hno="/>
      <button type="submit">Launch the tool</button>
    </form>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment