2 Commits

Author SHA1 Message Date
  Carlos Hernandez 8604219fd5 Find way to display articles content from API 2 years ago
  Carlos Hernandez f3b526ab63 Find way to display articles content from API 2 years ago
2 changed files with 6 additions and 3 deletions
  1. 3
    0
      .gitignore
  2. 3
    3
      Files-API/files_api.py

+ 3
- 0
.gitignore View File

@@ -1,3 +1,6 @@
1
+# Local
2
+.vscode
3
+
1 4
 # Byte-compiled / optimized / DLL files
2 5
 __pycache__/
3 6
 *.py[cod]

+ 3
- 3
Files-API/files_api.py View File

@@ -1,5 +1,5 @@
1 1
 import os
2
-from flask import Flask, send_from_directory, jsonify
2
+from flask import Flask, send_from_directory, jsonify, current_app
3 3
 from flask_cors import CORS, cross_origin
4 4
 
5 5
 
@@ -20,8 +20,8 @@ def send_text_file(article):
20 20
 @cross_origin(origin="localhost", headers=["Content-Type", "Authorization"])
21 21
 def list_files():
22 22
     files = list()
23
-    for filename in os.listdir("articles"):
24
-        path = os.path.join("articles", filename)
23
+    for filename in os.listdir(os.path.join(current_app.root_path, "articles")):
24
+        path = os.path.join(current_app.root_path, "articles", filename)
25 25
         if os.path.isfile(path):
26 26
             files.append(filename)
27 27
     return jsonify(files)