Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix URL generation to better support serving behind proxy #451

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion justpy/justpy.py
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ async def on_disconnect(self, page_id):
return JSONResponse(False)


@app.websocket_route("/")
@app.websocket_route("/", name="ws")
class JustpyEvents(WebSocketEndpoint):

socket_id = 0
Expand Down
2 changes: 1 addition & 1 deletion justpy/templates/highcharts.html
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
{#Must be last#}
<script src="https://code.highcharts.com/stock/modules/boost.js"></script>
{% else %}
<script src="/templates/local/highcharts.js"></script>
<script src="{{ url_for('templates', path='/local/highcharts.js') }}"></script>
{% endif %}


Expand Down
7 changes: 2 additions & 5 deletions justpy/templates/main.html
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,8 @@
} else {
protocol_string = 'ws://'
}
if (location.port) {
var socket = new WebSocket(protocol_string + document.domain + ':' + location.port);
} else {
var socket = new WebSocket(protocol_string + document.domain);
}
const wsURL = '{{ url_for('ws') }}';
var socket = new WebSocket(wsURL);

socket.addEventListener('open', function (event) {
console.log('Webocket opened');
Expand Down
4 changes: 2 additions & 2 deletions justpy/templates/optional_packages.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@
{% if not options.no_internet %}
<script src="https://unpkg.com/ag-grid-community/dist/ag-grid-community.min.js"></script>
{% else %}
<script src="/templates/local/ag-grid-community.js"></script>
<script src="{{ url_for('templates', path='/local/ag-grid-community.js') }}"></script>
{% endif %}
{% endif %}

{% if options.aggrid_enterprise %}
{% if not options.no_internet %}
<script src="https://unpkg.com/ag-grid-enterprise/dist/ag-grid-enterprise.min.js"></script>
{% else %}
<script src="/templates/local/ag-grid-enterprise.js"></script>
<script src="{{ url_for('templates', path='/local/ag-grid-enterprise.js') }}"></script>
{% endif %}
{% endif %}

Expand Down
26 changes: 13 additions & 13 deletions justpy/templates/quasar.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@
<link rel="stylesheet" href="https://unpkg.com/@tailwindcss/typography@0.4.x/dist/typography.min.css">
<link rel="stylesheet" href="https://unpkg.com/tailwindcss@^2.0/dist/utilities.min.css">
{% else %}
<link href="/templates/local/tailwind/base.css" rel="stylesheet">
<link href="/templates/local/tailwind/components.css" rel="stylesheet">
<link href="/templates/local/tailwind/typography.css" rel="stylesheet">
<link href="/templates/local/tailwind/utilities.css" rel="stylesheet">
<link href="{{ url_for('templates', path='/local/tailwind/base.css') }}" rel="stylesheet">
<link href="{{ url_for('templates', path='/local/tailwind/components.css') }}" rel="stylesheet">
<link href="{{ url_for('templates', path='/local/tailwind/typography.css') }}" rel="stylesheet">
<link href="{{ url_for('templates', path='/local/tailwind/utilities.css') }}" rel="stylesheet">
{% endif %}
<style>
{% include 'css/form.css' %}
Expand All @@ -36,12 +36,12 @@
type="text/css">
{% endif %}
{% else %}
<link rel="stylesheet" href="/templates/local/robotofont/robotofont.css"/>
<link rel="stylesheet" href="/templates/local/ionicons/ionicons.css"/>
<link rel="stylesheet" href="/templates/local/materialdesignicons/iconfont/material-icons.css"/>
<link rel="stylesheet" href="/templates/local/fontawesome/css/all.min.css"/>
<link rel="stylesheet" href="/templates/local/animate.css"/>
<link rel="stylesheet" href="/templates/local/quasar.css"/>
<link rel="stylesheet" href="{{ url_for('templates', path='/local/robotofont/robotofont.css') }}"/>
<link rel="stylesheet" href="{{ url_for('templates', path='/local/ionicons/ionicons.css') }}"/>
<link rel="stylesheet" href="{{ url_for('templates', path='/local/materialdesignicons/iconfont/material-icons.css') }}"/>
<link rel="stylesheet" href="{{ url_for('templates', path='/local/fontawesome/css/all.min.css') }}"/>
<link rel="stylesheet" href="{{ url_for('templates', path='/local/animate.css') }}"/>
<link rel="stylesheet" href="{{ url_for('templates', path='/local/quasar.css') }}"/>
{% endif %}

<style>
Expand Down Expand Up @@ -71,9 +71,9 @@
{% endif %}

{% else %}
<script src="/templates/local/jquery.js"></script>
<script src="/templates/local/vue.js"></script>
<script src="/templates/local/quasar.js"></script>
<script src="{{ url_for('templates', path='/local/jquery.js') }}"></script>
<script src="{{ url_for('templates', path='/local/vue.js') }}"></script>
<script src="{{ url_for('templates', path='/local/quasar.js') }}"></script>
{% endif %}

<div id="components">
Expand Down
16 changes: 8 additions & 8 deletions justpy/templates/tailwind.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@
<link rel="stylesheet" href="https://unpkg.com/@tailwindcss/typography@0.4.x/dist/typography.min.css">
<link rel="stylesheet" href="https://unpkg.com/tailwindcss@^2.0/dist/utilities.min.css">
{% else %}
<link href="/templates/local/tailwind/base.css" rel="stylesheet">
<link href="/templates/local/tailwind/components.css" rel="stylesheet">
<link href="/templates/local/tailwind/typography.css" rel="stylesheet">
<link href="/templates/local/tailwind/utilities.css" rel="stylesheet">
<link href="{{ url_for('templates', path='/local/tailwind/base.css') }}" rel="stylesheet">
<link href="{{ url_for('templates', path='/local/tailwind/components.css') }}" rel="stylesheet">
<link href="{{ url_for('templates', path='/local/tailwind/typography.css') }}" rel="stylesheet">
<link href="{{ url_for('templates', path='/local/tailwind/utilities.css') }}" rel="stylesheet">
{% endif %}
<style>
{% include 'css/form.css' %}
Expand All @@ -27,8 +27,8 @@
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.9.0/css/all.css"/>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/animate.css/3.7.0/animate.min.css"/>
{% else %}
<link rel="stylesheet" href="/templates/local/fontawesome/css/all.min.css"/>
<link rel="stylesheet" href="/templates/local/animate.css"/>
<link rel="stylesheet" href="{{ url_for('templates', path='/local/fontawesome/css/all.min.css') }}"/>
<link rel="stylesheet" href="{{ url_for('templates', path='/local/animate.css') }}"/>
{% endif %}

<style>
Expand All @@ -42,8 +42,8 @@
<script src="https://code.jquery.com/jquery-3.3.1.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.6.11/vue.min.js"></script>
{% else %}
<script src="/templates/local/jquery.js"></script>
<script src="/templates/local/vue.js"></script>
<script src="{{ url_for('templates', path='/local/jquery.js') }}"></script>
<script src="{{ url_for('templates', path='/local/vue.js') }}"></script>
{% endif %}
{% endif %}

Expand Down
16 changes: 8 additions & 8 deletions justpy/templates/tailwindui.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@tailwindcss/ui@latest/dist/tailwind-ui.min.css">
<link rel="stylesheet" href="https://unpkg.com/@tailwindcss/typography@/dist/typography.min.css">
{% else %}
<link href="/templates/local/tailwindui.css" rel="stylesheet">
<link href="/templates/local/tailwind/typography.css" rel="stylesheet">
<link href="{{ url_for('templates', path='/local/tailwindui.css') }}" rel="stylesheet">
<link href="{{ url_for('templates', path='/local/tailwind/typography.css') }}" rel="stylesheet">

{% endif %}
<style>
Expand All @@ -24,8 +24,8 @@
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.9.0/css/all.css"/>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/animate.css/3.7.0/animate.min.css"/>
{% else %}
<link rel="stylesheet" href="/templates/local/fontawesome/css/all.min.css"/>
<link rel="stylesheet" href="/templates/local/animate.css"/>
<link rel="stylesheet" href="{{ url_for('templates', path='/local/fontawesome/css/all.min.css') }}"/>
<link rel="stylesheet" href="{{ url_for('templates', path='/local/animate.css') }}"/>
{% endif %}

<style>
Expand All @@ -39,8 +39,8 @@
<script src="https://code.jquery.com/jquery-3.3.1.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.6.11/vue.min.js"></script>
{% else %}
<script src="/templates/local/jquery.js"></script>
<script src="/templates/local/vue.js"></script>
<script src="{{ url_for('templates', path='/local/jquery.js') }}"></script>
<script src="{{ url_for('templates', path='/local/vue.js') }}"></script>
{% endif %}
{% endif %}

Expand All @@ -52,15 +52,15 @@
{% if not options.no_internet %}
<script src="https://unpkg.com/ag-grid-community/dist/ag-grid-community.min.js"></script>
{% else %}
<script src="/templates/local/ag-grid-community.js"></script>
<script src="{{ url_for('templates', path='/local/ag-grid-community.js') }}"></script>
{% endif %}
{% endif %}

{% if options.aggrid_enterprise %}
{% if not options.no_internet %}
<script src="https://unpkg.com/ag-grid-enterprise/dist/ag-grid-enterprise.min.js"></script>
{% else %}
<script src="/templates/local/ag-grid-enterprise.js"></script>
<script src="{{ url_for('templates', path='/local/ag-grid-enterprise.js') }}"></script>
{% endif %}
{% endif %}
</head>
Expand Down