Skip to content

Commit

Permalink
redirect per #17
Browse files Browse the repository at this point in the history
  • Loading branch information
paulgb committed Jun 23, 2019
1 parent c67e535 commit 741399d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
11 changes: 8 additions & 3 deletions server/notify_run_server/app.py
@@ -1,6 +1,6 @@
from io import BytesIO

from flask import Flask, Response, jsonify, request
from flask import Flask, Response, jsonify, request, redirect
from flask_cors import CORS
from pyqrcode import QRCode

Expand Down Expand Up @@ -43,11 +43,11 @@ def to_python(self, value):


def channel_page_url(channel_id):
return (WEB_SERVER or request.host) + '/c/' + channel_id
return (WEB_SERVER or request.url_root[:-1]) + '/c/' + channel_id


def channel_endpoint(channel_id):
return (API_SERVER or request.host) + '/' + channel_id
return (API_SERVER or request.url_root[:-1]) + '/' + channel_id


def qr_for_channel(channel_id):
Expand Down Expand Up @@ -98,6 +98,11 @@ def info(channel_id):


@app.route('/<chid:channel_id>', methods=['GET'])
def redirect_channel(channel_id):
return redirect(channel_page_url(channel_id))


@app.route('/<chid:channel_id>/json', methods=['GET'])
def get_channel(channel_id):
try:
channel = model.get_channel(channel_id)
Expand Down
2 changes: 1 addition & 1 deletion site/src/api.ts
Expand Up @@ -33,7 +33,7 @@ export namespace NotifyAPI {
}

export function fetchChannel(channelId: string): Promise<ChannelResponse> {
return request(`/${channelId}`);
return request(`/${channelId}/json`);
}

export function getURLOfQR(channelId: string): string {
Expand Down

0 comments on commit 741399d

Please sign in to comment.