├── README.md
├── app.py
├── requirements.txt
├── templates
└── index.html
└── vercel.json
/README.md:
--------------------------------------------------------------------------------
1 |
KnowUnity PDF Downloader
2 |
3 | `Get PDF Link from the link given by the app or the website`
4 |
5 | **How to install locally the project:**
6 |
7 | - Clone the repository on your machine.
8 | - Install the Python dependencies by running ```pip install -r requirements.txt```.
9 | - Launch the web server by running ```python app.py```.
10 | - Go to http://localhost:5000/ in your browser.
11 | - Enter a URL in the form and press the "Get PDF Link!" button.
--------------------------------------------------------------------------------
/app.py:
--------------------------------------------------------------------------------
1 | from flask import Flask, render_template, request, jsonify
2 | import requests
3 | import re
4 |
5 | app = Flask(__name__)
6 |
7 | @app.route('/', methods=['GET', 'POST'])
8 | def index():
9 | url = None
10 | if request.method == 'POST':
11 | input_url = request.form['url']
12 | know_id = extract_know_id(input_url)
13 | if know_id:
14 | url = get_content_url(know_id)
15 | return render_template('index.html', url=url)
16 |
17 | def extract_know_id(input_url):
18 | match = re.search(r"[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}", input_url)
19 | return match.group(0) if match else None
20 |
21 | def get_content_url(know_id):
22 | api_url = f'https://apiedge-eu-central-1.knowunity.com/knows/{know_id}'
23 | response = requests.get(api_url)
24 | if response.status_code == 200:
25 | json_data = response.json()
26 | return json_data['documents'][0]['contentUrl']
27 | return None
28 |
29 | if __name__ == '__main__':
30 | app.run()
--------------------------------------------------------------------------------
/requirements.txt:
--------------------------------------------------------------------------------
1 | Flask
2 | requests
--------------------------------------------------------------------------------
/templates/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | KnowUnity PDF Downloader
7 |
77 |
78 |
79 | KnowUnity PDF Downloader
80 |
85 | {% if url %}
86 | PDF Link :
87 | {{ url }}
88 | {% endif %}
89 |
90 |
--------------------------------------------------------------------------------
/vercel.json:
--------------------------------------------------------------------------------
1 | {
2 | "builds": [
3 | {
4 | "src": "app.py",
5 | "use": "@vercel/python"
6 | }
7 | ],
8 | "routes": [
9 | {
10 | "src": "/(.*)",
11 | "dest": "app.py"
12 | }
13 | ]
14 | }
15 |
--------------------------------------------------------------------------------