diff --git a/main.py b/main.py index 91c7900..1b0ada8 100644 --- a/main.py +++ b/main.py @@ -7,3 +7,4 @@ import requests, sqlite3, json from mastodon import Mastodon +cfg = json.load(open('meta.json')) diff --git a/static/script.js b/static/script.js index 7bf06f2..aabdd2f 100644 --- a/static/script.js +++ b/static/script.js @@ -35,8 +35,6 @@ async function ajax(url) { //must be called from an async function! use 'await', async function cont() { url = dgel('instance-input').value; - if (url.substr(0,8) != "https://") { - url = "https://" + url - } - + j = await ajax('/internal/auth_a?url=' + url) + console.log(j) } \ No newline at end of file diff --git a/templates/landing_page.html b/templates/landing_page.html index 0977208..b5e4ae2 100644 --- a/templates/landing_page.html +++ b/templates/landing_page.html @@ -9,6 +9,9 @@

Curious Greg

Connect your Curious Cat and Mastodon accounts for automated crossposting.

+

@@ -17,6 +20,7 @@
\ No newline at end of file diff --git a/web.py b/web.py index 3f2d130..ef7c695 100755 --- a/web.py +++ b/web.py @@ -6,7 +6,7 @@ import requests, sqlite3, json from mastodon import Mastodon -from flask import Flask, render_template +from flask import Flask, render_template, request cfg = json.load(open("meta.json")) @@ -24,14 +24,18 @@ def main(): @app.route('/internal/auth_a') def internal_auth_a(): + + client_id = "abc" + client_secret = "123" + instance_url = request.args.get('url', default='mastodon.social', type=str) + if not instance_url.startswith("https://"): + instance_url = "https://{}".format(instance_url) + # client_id, client_secret = Mastodon.create_app(cfg['name'], # api_base_url=instance_url, # scopes="write:statuses", # website=cfg['website']) - client_id = "abc" - client_secret = "123" - client_info = { "client_id": client_id, "client_secret":client_secret,