Skip to content

Commit 3d269e1

Browse files
committed
initial file upload
1 parent 5293c4b commit 3d269e1

File tree

1,770 files changed

+102155
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,770 files changed

+102155
-0
lines changed

EmbedPortal.py

Lines changed: 141 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,141 @@
1+
# import Flask library (class) that has needed functionality to build Web Server
2+
# import render_template - this is library that works with Flask Jinja (HTML) templates
3+
# import request - to access incoming request data, you can use the global request object.
4+
# Flask parses incoming request data for you and gives you access to it through that global object.
5+
# import flask_wtf and wtfforms are libraries that will help us with the form data
6+
7+
from flask import Flask, render_template, request
8+
from flask_cors import CORS, cross_origin
9+
from flask_wtf import FlaskForm
10+
from wtforms import StringField, validators
11+
12+
import requests
13+
import datetime
14+
import json
15+
import uuid
16+
import jwt
17+
18+
app = Flask(__name__)
19+
CORS(app)
20+
cors = CORS(app, resources={
21+
r"/*":{
22+
"origins": "*"
23+
}
24+
})
25+
app.debug = True
26+
app.config['SEND_FILE_MAX_AGE_DEFAULT'] = 0
27+
@app.after_request
28+
def after_request(response):
29+
response.headers["Cache-Control"] = "no-cache, no-store, must-revalidate, public, max-age=0"
30+
response.headers["Expires"] = 0
31+
response.headers["Pragma"] = "no-cache"
32+
return response
33+
34+
# initializing global variables
35+
username = ''
36+
tabServer = 'http://localhost:8000'
37+
38+
39+
# this secret key is here a string just so we have forms working - if you want to know more google it ;-)
40+
app.config['SECRET_KEY'] = 'somesecretkey'
41+
42+
# instance the form class - inheritance is from the FlaskForm.
43+
# You can name the calss as you like - we named it "UserForm"
44+
class UserForm(FlaskForm):
45+
# Below are the form fields we want to be able to capture and send (in our case just the username) to Tableau server.
46+
# These are used as form attributes in .html file
47+
# in the quotes is the text user will see when using the form
48+
username = StringField("Username:", validators=[validators.DataRequired()])
49+
50+
##########Rendering the login page##########
51+
@app.route('/')
52+
def index():
53+
return render_template('index.html')
54+
55+
@app.route('/login2')
56+
def login2():
57+
return render_template('login2.html')
58+
@app.route('/login3')
59+
def login3():
60+
return render_template('login3.html')
61+
@app.route('/login9')
62+
def login9():
63+
return render_template('login9.html')
64+
65+
@app.route('/test')
66+
def test():
67+
return render_template('loader.html')
68+
69+
@app.route('/loadingCA', methods=['GET','POST'])
70+
@cross_origin()
71+
def getJWT():
72+
global username
73+
if request.method == 'POST':
74+
username = request.form['username']
75+
print(username)
76+
CA_SSO_token = jwt.encode(
77+
{
78+
"iss": 'ff3ad96c-1d60-4ff2-89ee-02e99fe551ad',
79+
"exp": datetime.datetime.utcnow() + datetime.timedelta(minutes=10),
80+
"jti": str(uuid.uuid4()),
81+
"aud": "tableau",
82+
"sub": username,
83+
"scp": ["tableau:views:embed", "tableau:metrics:embed"]
84+
},
85+
'0/oP45C+hQ8YY8+EZs/I6+SbTCU+BVYnlimq7fkRHk0=',
86+
algorithm="HS256",
87+
headers={
88+
'kid': '784f8c48-e657-4245-b887-8bbd45bd40f0',
89+
'iss': 'ff3ad96c-1d60-4ff2-89ee-02e99fe551ad'
90+
}
91+
)
92+
93+
headers = {
94+
'Access-Control-Allow-Origin': '*',
95+
'content-type': 'application/json'
96+
}
97+
98+
print("Here's your JWT!: \n" + CA_SSO_token)
99+
if request.form['route'] =='2':
100+
return render_template('loader2.html', CA_SSO_token=CA_SSO_token,tabServer = tabServer,username=username)
101+
if request.form['route'] =='3':
102+
return render_template('loader3.html', CA_SSO_token=CA_SSO_token,tabServer = tabServer,username=username)
103+
if request.form['route'] =='9':
104+
return render_template('loader9.html', CA_SSO_token=CA_SSO_token,tabServer = tabServer,username=username)
105+
106+
@app.route('/lesson1')
107+
def loadLesson1():
108+
return render_template('lesson1.html', username = username, tabServer = tabServer)
109+
@app.route('/lesson2')
110+
def loadLesson2():
111+
return render_template('lesson2.html', username = username, tabServer = tabServer)
112+
@app.route('/lesson3_1')
113+
def loadLesson3_1():
114+
return render_template('lesson3_1.html', username = username, tabServer = tabServer)
115+
@app.route('/lesson3_2_1')
116+
def loadLesson3_2_1():
117+
return render_template('lesson3_2_1.html', username = username, tabServer = tabServer)
118+
@app.route('/lesson3_2_2')
119+
def loadLesson3_2_2():
120+
return render_template('lesson3_2_2.html', username = username, tabServer = tabServer)
121+
@app.route('/lesson3_3')
122+
def loadLesson3_3():
123+
return render_template('lesson3_3.html', username = username, tabServer = tabServer)
124+
@app.route('/lesson3_4')
125+
def loadLesson3_4():
126+
return render_template('lesson3_4.html', username = username, tabServer = tabServer)
127+
128+
129+
@app.route('/complete')
130+
def loadcomplete():
131+
return render_template('complete.html', username = username, tabServer = tabServer)
132+
133+
134+
135+
136+
@app.route('/ask')
137+
def askData():
138+
return render_template('askdata.html', username = username, tabServer = tabServer)
139+
140+
if __name__ == '__main__':
141+
app.run(host='0.0.0.0', port=80)

RedirectPage.twbx

435 KB
Binary file not shown.

Superstore Data.tdsx

1.1 MB
Binary file not shown.

batch.log

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
===== Creating new session
2+
===== Server: http://localhost:8000
3+
===== Username: admin
4+
===== Connecting to the server...
5+
===== Signing in...
6+
===== Succeeded
7+
===== Continuing previous session
8+
===== Server: http://localhost:8000
9+
===== Username: admin
10+
===== Upload progress: 90.55%
11+
===== Upload progress: 100%
12+
===== Publishing 'Superstore Data.tdsx' to the server. This could take several minutes...
13+
===== File successfully published to the server at the following location:
14+
===== http://localhost:8000/datasources/SuperstoreData
15+
===== Continuing previous session
16+
===== Server: http://localhost:8000
17+
===== Username: admin
18+
===== Publishing 'tc_viz.twbx' to the server. This could take several minutes...
19+
===== File successfully published to the server at the following location:
20+
===== http://localhost:8000/workbooks/tc_viz
21+
===== Continuing previous session
22+
===== Server: http://localhost:8000
23+
===== Username: admin
24+
===== Publishing 'RedirectPage.twbx' to the server. This could take several minutes...
25+
===== redirecting to http://localhost:8000/auth
26+
===== Signed out

publish.bat

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
@echo off
2+
set LOGFILE=batch.log
3+
call :LOG > %LOGFILE%
4+
exit /B
5+
6+
:LOG
7+
8+
tabcmd login --server http://localhost:8000 --username admin --password admin
9+
10+
tabcmd publish "Superstore Data.tdsx" -n "Superstore Data"
11+
12+
tabcmd publish "tc_viz.twbx" -n "tc_viz"
13+
14+
tabcmd publish "RedirectPage.twbx" -n "RedirectPage"
15+
16+
tabcmd logout

requirements.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
Flask==2.1.1
2+
Flask_Cors==3.0.10
3+
Flask_WTF==1.0.1
4+
PyJWT==2.3.0
5+
requests==2.27.1
6+
WTForms==3.0.1

0 commit comments

Comments
 (0)