-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathapp.py
77 lines (50 loc) · 2.14 KB
/
app.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
"""
The app.py contains initial Flask app. This is the entry point for all further interaction.
Here, all routes are listed.
Methods:
find_path_to_folder(): Find the path to the folder where the documentation information is stored.
get_web_page_info(about): Get the information of a specific part of the documentation.
get_all_infos_webpage(): Get the documentation information of all parts of the website.
"""
from flask import Flask, jsonify, render_template, request
from utils import config_helper, webpage_helper, search_engine, helper_functions
from controller.entry_controller import EntryController
app = Flask(__name__)
@app.route('/')
def index():
"""Render the website.
:return:
"""
return render_template('index.html')
@app.route('/get_all_configs')
def get_all_configs():
"""Get all configuration information and return it to the website.
:return: A JSON that contains all configuration data
"""
return jsonify(config_helper.get_all_configs())
@app.route('/get_all_webpage_infos')
def get_all_webpage_infos():
"""Get all information for the website like a How-To text, imprint, credits, ... etc.
:return: A JSON containing all information for the website
"""
return jsonify(webpage_helper.get_all_infos_webpage())
@app.route('/conduct_search')
def conduct_search():
"""Ask the query to the search engine and return the results to the client.
:return: a JSON file with the search results
"""
return jsonify(search_engine.search(request.args.get('query')))
@app.route('/get_framework')
def get_framework():
"""Get all entries of specified framework and return them to the website.
:return: A JSON containing all entries of a framework
"""
return jsonify(helper_functions.get_all_fields(request.args.get('framework')))
@app.route('/write_json', methods=['POST'])
def write_json():
"""Write the JSON file containing all selected entries, pack it into a ZIP file and return it to the website for
download by the user.
:return: A ZIP file containing the JSON file(s) with the selected entries
"""
return EntryController().write_json()
app.run()