Skip to content

Commit 85d74e3

Browse files
authored
Merge pull request #1 from Syn3rman/master
Flask app setup
2 parents 2b5f148 + ecf58df commit 85d74e3

File tree

2 files changed

+38
-0
lines changed

2 files changed

+38
-0
lines changed

app.py

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
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)

data/adi.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"name": "Aditya Prajapati",
3+
"friends": []
4+
}

0 commit comments

Comments
 (0)