Skip to content

Commit

Permalink
initial file upload
Browse files Browse the repository at this point in the history
  • Loading branch information
stephenlprice committed Apr 22, 2022
1 parent 5293c4b commit 3d269e1
Show file tree
Hide file tree
Showing 1,770 changed files with 102,155 additions and 0 deletions.
141 changes: 141 additions & 0 deletions EmbedPortal.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
# import Flask library (class) that has needed functionality to build Web Server
# import render_template - this is library that works with Flask Jinja (HTML) templates
# import request - to access incoming request data, you can use the global request object.
# Flask parses incoming request data for you and gives you access to it through that global object.
# import flask_wtf and wtfforms are libraries that will help us with the form data

from flask import Flask, render_template, request
from flask_cors import CORS, cross_origin
from flask_wtf import FlaskForm
from wtforms import StringField, validators

import requests
import datetime
import json
import uuid
import jwt

app = Flask(__name__)
CORS(app)
cors = CORS(app, resources={
r"/*":{
"origins": "*"
}
})
app.debug = True
app.config['SEND_FILE_MAX_AGE_DEFAULT'] = 0
@app.after_request
def after_request(response):
response.headers["Cache-Control"] = "no-cache, no-store, must-revalidate, public, max-age=0"
response.headers["Expires"] = 0
response.headers["Pragma"] = "no-cache"
return response

# initializing global variables
username = ''
tabServer = 'http://localhost:8000'


# this secret key is here a string just so we have forms working - if you want to know more google it ;-)
app.config['SECRET_KEY'] = 'somesecretkey'

# instance the form class - inheritance is from the FlaskForm.
# You can name the calss as you like - we named it "UserForm"
class UserForm(FlaskForm):
# Below are the form fields we want to be able to capture and send (in our case just the username) to Tableau server.
# These are used as form attributes in .html file
# in the quotes is the text user will see when using the form
username = StringField("Username:", validators=[validators.DataRequired()])

##########Rendering the login page##########
@app.route('/')
def index():
return render_template('index.html')

@app.route('/login2')
def login2():
return render_template('login2.html')
@app.route('/login3')
def login3():
return render_template('login3.html')
@app.route('/login9')
def login9():
return render_template('login9.html')

@app.route('/test')
def test():
return render_template('loader.html')

@app.route('/loadingCA', methods=['GET','POST'])
@cross_origin()
def getJWT():
global username
if request.method == 'POST':
username = request.form['username']
print(username)
CA_SSO_token = jwt.encode(
{
"iss": 'ff3ad96c-1d60-4ff2-89ee-02e99fe551ad',
"exp": datetime.datetime.utcnow() + datetime.timedelta(minutes=10),
"jti": str(uuid.uuid4()),
"aud": "tableau",
"sub": username,
"scp": ["tableau:views:embed", "tableau:metrics:embed"]
},
'0/oP45C+hQ8YY8+EZs/I6+SbTCU+BVYnlimq7fkRHk0=',
algorithm="HS256",
headers={
'kid': '784f8c48-e657-4245-b887-8bbd45bd40f0',
'iss': 'ff3ad96c-1d60-4ff2-89ee-02e99fe551ad'
}
)

headers = {
'Access-Control-Allow-Origin': '*',
'content-type': 'application/json'
}

print("Here's your JWT!: \n" + CA_SSO_token)
if request.form['route'] =='2':
return render_template('loader2.html', CA_SSO_token=CA_SSO_token,tabServer = tabServer,username=username)
if request.form['route'] =='3':
return render_template('loader3.html', CA_SSO_token=CA_SSO_token,tabServer = tabServer,username=username)
if request.form['route'] =='9':
return render_template('loader9.html', CA_SSO_token=CA_SSO_token,tabServer = tabServer,username=username)

@app.route('/lesson1')
def loadLesson1():
return render_template('lesson1.html', username = username, tabServer = tabServer)
@app.route('/lesson2')
def loadLesson2():
return render_template('lesson2.html', username = username, tabServer = tabServer)
@app.route('/lesson3_1')
def loadLesson3_1():
return render_template('lesson3_1.html', username = username, tabServer = tabServer)
@app.route('/lesson3_2_1')
def loadLesson3_2_1():
return render_template('lesson3_2_1.html', username = username, tabServer = tabServer)
@app.route('/lesson3_2_2')
def loadLesson3_2_2():
return render_template('lesson3_2_2.html', username = username, tabServer = tabServer)
@app.route('/lesson3_3')
def loadLesson3_3():
return render_template('lesson3_3.html', username = username, tabServer = tabServer)
@app.route('/lesson3_4')
def loadLesson3_4():
return render_template('lesson3_4.html', username = username, tabServer = tabServer)


@app.route('/complete')
def loadcomplete():
return render_template('complete.html', username = username, tabServer = tabServer)




@app.route('/ask')
def askData():
return render_template('askdata.html', username = username, tabServer = tabServer)

if __name__ == '__main__':
app.run(host='0.0.0.0', port=80)
Binary file added RedirectPage.twbx
Binary file not shown.
Binary file added Superstore Data.tdsx
Binary file not shown.
26 changes: 26 additions & 0 deletions batch.log
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
===== Creating new session
===== Server: http://localhost:8000
===== Username: admin
===== Connecting to the server...
===== Signing in...
===== Succeeded
===== Continuing previous session
===== Server: http://localhost:8000
===== Username: admin
===== Upload progress: 90.55%
===== Upload progress: 100%
===== Publishing 'Superstore Data.tdsx' to the server. This could take several minutes...
===== File successfully published to the server at the following location:
===== http://localhost:8000/datasources/SuperstoreData
===== Continuing previous session
===== Server: http://localhost:8000
===== Username: admin
===== Publishing 'tc_viz.twbx' to the server. This could take several minutes...
===== File successfully published to the server at the following location:
===== http://localhost:8000/workbooks/tc_viz
===== Continuing previous session
===== Server: http://localhost:8000
===== Username: admin
===== Publishing 'RedirectPage.twbx' to the server. This could take several minutes...
===== redirecting to http://localhost:8000/auth
===== Signed out
16 changes: 16 additions & 0 deletions publish.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
@echo off
set LOGFILE=batch.log
call :LOG > %LOGFILE%
exit /B

:LOG

tabcmd login --server http://localhost:8000 --username admin --password admin

tabcmd publish "Superstore Data.tdsx" -n "Superstore Data"

tabcmd publish "tc_viz.twbx" -n "tc_viz"

tabcmd publish "RedirectPage.twbx" -n "RedirectPage"

tabcmd logout
6 changes: 6 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Flask==2.1.1
Flask_Cors==3.0.10
Flask_WTF==1.0.1
PyJWT==2.3.0
requests==2.27.1
WTForms==3.0.1
Loading

0 comments on commit 3d269e1

Please sign in to comment.