File tree 2 files changed +38
-0
lines changed
2 files changed +38
-0
lines changed Original file line number Diff line number Diff line change
1
+ from flask import Flask
2
+ from flask import request , jsonify , render_template
3
+ import os
4
+ import json
5
+
6
+ # Home page route With cards
7
+ # Comic page
8
+
9
+ app = Flask (__name__ )
10
+
11
+ @app .route ('/' )
12
+ def test ():
13
+ path = 'data/'
14
+ files = os .listdir (path )
15
+ result = []
16
+ for file in files :
17
+ with open ("data/" + file , 'r' ) as f :
18
+ result .append (json .load (f ))
19
+ print (result )
20
+ return "Hello akshay"
21
+
22
+ @app .route ('/<name>' )
23
+ def get_contents (name ):
24
+ try :
25
+ with open (f"data/{ name } .json" , 'r' ) as f :
26
+ return jsonify (json .load (f ))
27
+ except :
28
+ return jsonify ({
29
+ 'msg' : 'File not found' ,
30
+ 'success' : False
31
+ })
32
+
33
+ if __name__ == '__main__' :
34
+ app .run (host = '0.0.0.0' , port = 1233 )
Original file line number Diff line number Diff line change
1
+ {
2
+ "name" : " Aditya Prajapati" ,
3
+ "friends" : []
4
+ }
You can’t perform that action at this time.
0 commit comments