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
+# Local
2
+.vscode
3
+
1
 # Byte-compiled / optimized / DLL files
4
 # Byte-compiled / optimized / DLL files
2
 __pycache__/
5
 __pycache__/
3
 *.py[cod]
6
 *.py[cod]

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

1
 import os
1
 import os
2
-from flask import Flask, send_from_directory, jsonify
2
+from flask import Flask, send_from_directory, jsonify, current_app
3
 from flask_cors import CORS, cross_origin
3
 from flask_cors import CORS, cross_origin
4
 
4
 
5
 
5
 
20
 @cross_origin(origin="localhost", headers=["Content-Type", "Authorization"])
20
 @cross_origin(origin="localhost", headers=["Content-Type", "Authorization"])
21
 def list_files():
21
 def list_files():
22
     files = list()
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
         if os.path.isfile(path):
25
         if os.path.isfile(path):
26
             files.append(filename)
26
             files.append(filename)
27
     return jsonify(files)
27
     return jsonify(files)