search-api-webui 0.1.0__py3-none-any.whl → 0.1.1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
backend/app.py CHANGED
@@ -4,27 +4,41 @@ from flask import Flask, request, jsonify, send_from_directory
4
4
  from flask_cors import CORS
5
5
  from backend.providers import load_providers
6
6
 
7
+ CURRENT_DIR = Path(__file__).resolve().parent
8
+ STATIC_FOLDER = CURRENT_DIR / 'static'
9
+
7
10
  app = Flask(__name__, static_folder='static')
8
11
  CORS(app)
9
12
 
10
- BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
11
- PROVIDERS_YAML = os.path.join(BASE_DIR, 'providers.yaml')
12
- USER_CONFIG_JSON = os.path.join(BASE_DIR, 'user_config.json')
13
+ PROVIDERS_YAML = CURRENT_DIR / 'providers.yaml'
14
+ USER_CONFIG_DIR = Path.home() / '.search-api-webui'
15
+ USER_CONFIG_JSON = USER_CONFIG_DIR / 'config.json'
16
+
17
+ if not USER_CONFIG_DIR.exists():
18
+ USER_CONFIG_DIR.mkdir(parents=True, exist_ok=True)
13
19
 
14
- provider_map = load_providers(PROVIDERS_YAML)
20
+ if PROVIDERS_YAML.exists():
21
+ provider_map = load_providers(str(PROVIDERS_YAML))
22
+ else:
23
+ print(f"Error: Configuration file not found at {PROVIDERS_YAML}")
24
+ provider_map = {}
15
25
 
16
26
  def get_stored_config():
17
- if not os.path.exists(USER_CONFIG_JSON):
27
+ if not USER_CONFIG_JSON.exists():
18
28
  return {}
19
29
  try:
20
- with open(USER_CONFIG_JSON, 'r') as f:
30
+ with open(USER_CONFIG_JSON, 'r', encoding='utf-8') as f:
21
31
  return json.load(f)
22
- except:
32
+ except Exception as e:
33
+ print(f"Error reading config: {e}")
23
34
  return {}
24
35
 
25
36
  def save_stored_config(config_dict):
26
- with open(USER_CONFIG_JSON, 'w') as f:
27
- json.dump(config_dict, f, indent=2)
37
+ try:
38
+ with open(USER_CONFIG_JSON, 'w', encoding='utf-8') as f:
39
+ json.dump(config_dict, f, indent=2)
40
+ except Exception as e:
41
+ print(f"Error saving config: {e}")
28
42
 
29
43
  @app.route('/api/providers', methods=['GET'])
30
44
  def get_providers_list():
@@ -127,10 +141,10 @@ def search_api():
127
141
  @app.route('/', defaults={'path': ''})
128
142
  @app.route('/<path:path>')
129
143
  def serve(path):
130
- if path != "" and os.path.exists(os.path.join(app.static_folder, path)):
131
- return send_from_directory(app.static_folder, path)
144
+ if path != "" and (STATIC_FOLDER / path).exists():
145
+ return send_from_directory(str(STATIC_FOLDER), path)
132
146
  else:
133
- return send_from_directory(app.static_folder, 'index.html')
147
+ return send_from_directory(str(STATIC_FOLDER), 'index.html')
134
148
 
135
149
  def main():
136
150
  import argparse
@@ -138,7 +152,11 @@ def main():
138
152
  parser.add_argument("--port", type=int, default=8889, help="Port to run the server on")
139
153
  parser.add_argument("--host", type=str, default="0.0.0.0", help="Host to run the server on")
140
154
  args = parser.parse_args()
141
-
155
+
156
+ print(f"Starting Search API WebUI...")
157
+ print(f" - Config Storage: {USER_CONFIG_JSON}")
158
+ print(f" - Serving on: http://{args.host}:{args.port}")
159
+
142
160
  app.run(host=args.host, port=args.port)
143
161
 
144
162
  if __name__ == "__main__":
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: search-api-webui
3
- Version: 0.1.0
3
+ Version: 0.1.1
4
4
  Summary: A Search API WebUI for Querit, You, and other search providers.
5
5
  Project-URL: Homepage, https://github.com/querit-ai/search-api-webui
6
6
  Project-URL: Repository, https://github.com/querit-ai/search-api-webui.git
@@ -1,5 +1,5 @@
1
1
  backend/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
- backend/app.py,sha256=J5GB0-rNOPq5Ny0DK5LDO_v0OqvUiMF7MM5Xk29aviM,4540
2
+ backend/app.py,sha256=6sKid3996ydT19Q04Eg0RY23PEJb0TIGWz_FRIxCDI8,5119
3
3
  backend/providers/__init__.py,sha256=l9SCd9sEISWZB-E2Co8ds2hILaxBVoh2S6SSg7MXXIo,1072
4
4
  backend/providers/base.py,sha256=_iYcxCxI7VCoxb02D71KqtojAU91D6rc3c5dwKNYJ2o,863
5
5
  backend/providers/generic.py,sha256=3dyx3Hpbo4hlfUcwy1wYt5N5dc2X3fK1iFnOoT3m_Vc,4440
@@ -8,8 +8,8 @@ backend/providers.yaml,sha256=2aRmfT7NmeU9IfUqX7phRjOf_fUACRD5ondYJO2HH4I,400
8
8
  backend/static/index.html,sha256=fhLWDY2W-bN-bBq2fmkch-e6gRZpoyqbKvNBzpWHiHk,401
9
9
  backend/static/assets/index-CF13bI2g.js,sha256=91wc8meWvRXloy4vzmGN43DvrpHIjMVIdCihXCw9zBU,208926
10
10
  backend/static/assets/index-DLyBd1PD.css,sha256=nevUEbN7Fw9cq3aXWV7v_tQpD00d7kr3I64dgZ-e7ys,17914
11
- search_api_webui-0.1.0.dist-info/METADATA,sha256=1xdpdSNV2TPkAGfio11onBkZp8yPjEn6Axk4KiJDAcM,2577
12
- search_api_webui-0.1.0.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
13
- search_api_webui-0.1.0.dist-info/entry_points.txt,sha256=D9R5N6s2Bt8rEKYSINTUB1f45nH-Xc5iIKNPfYYc8ec,54
14
- search_api_webui-0.1.0.dist-info/licenses/LICENSE,sha256=jHhlLwtvhZRz1yU1G_3cjsPigCTXQGT1qshhyekdmTE,1061
15
- search_api_webui-0.1.0.dist-info/RECORD,,
11
+ search_api_webui-0.1.1.dist-info/METADATA,sha256=b1YR8TsTbezT2uXKEYQFFcjA4aPqK9OFEBreHoIFiO8,2577
12
+ search_api_webui-0.1.1.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
13
+ search_api_webui-0.1.1.dist-info/entry_points.txt,sha256=D9R5N6s2Bt8rEKYSINTUB1f45nH-Xc5iIKNPfYYc8ec,54
14
+ search_api_webui-0.1.1.dist-info/licenses/LICENSE,sha256=jHhlLwtvhZRz1yU1G_3cjsPigCTXQGT1qshhyekdmTE,1061
15
+ search_api_webui-0.1.1.dist-info/RECORD,,