-
Notifications
You must be signed in to change notification settings - Fork 50
/
app.py
26 lines (22 loc) · 758 Bytes
/
app.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#Coded by Sumanjay on 29th Feb 2020
from flask import Flask, request, jsonify
from inshorts import getNews
from flask_cors import CORS
app = Flask(__name__)
app.secret_key = "i_am_not_feeling_sleepy_so_i_am_coding_this"
CORS(app)
@app.route('/')
def home():
return 'News API is UP!<br><br>A part of <a href="https://t.me/sjprojects">Sj Projects</a>'
@app.route('/news')
def news():
if request.method == 'GET':
category = request.args.get("category")
if not category:
return jsonify({
"error": "please add category in query params"
}), 404
return jsonify(getNews(category)), 200
if __name__ == '__main__':
app.debug = True
app.run(host='0.0.0.0',port=5000,use_reloader=True)