-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.py
39 lines (31 loc) · 1.72 KB
/
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
27
28
29
30
31
32
33
34
35
36
37
38
39
from flask import Flask, jsonify, request
from inshorts import getNews
from flask_cors import CORS
app = Flask(__name__)
app.secret_key = "LOVE_YOU_3000"
CORS(app)
@app.route('/')
def index():
return "API is UP and running"
@app.route('/categories')
def categories():
return "<a href = 'https://inshort.vandit.cf/shorts?category=all'>1. All News</a><br>" \
"<a href = 'https://inshort.vandit.cf/shorts?category=india'>2. India</a><br>" \
"<a href = 'https://inshort.vandit.cf/shorts?category=business'>3. Business</a><br>" \
"<a href = 'https://inshort.vandit.cf/shorts?category=sports'>4. sports</a><br>" \
"<a href = 'https://inshort.vandit.cf/shorts?category=world'>5. World</a><br>" \
"<a href = 'https://inshort.vandit.cf/shorts?category=politics'>6. Politics</a><br>" \
"<a href = 'https://inshort.vandit.cf/shorts?category=technology'>7. Technology</a><br>" \
"<a href = 'https://inshort.vandit.cf/shorts?category=startup'>8. Startup</a><br>" \
"<a href = 'https://inshort.vandit.cf/shorts?category=entertainment'>9. Entertainment</a><br>" \
"<a href = 'https://inshort.vandit.cf/shorts?category=miscellaneous'>10. Miscellaneous</a><br>" \
"<a href = 'https://inshort.vandit.cf/shorts?category=hatke'>11. Hatke</a><br>" \
"<a href = 'https://inshort.vandit.cf/shorts?category=science'>12. Science</a><br>" \
"<a href = 'https://inshort.vandit.cf/shorts?category=automobile'>13. Automobile</a><br>"
@app.route('/shorts')
def news():
if request.method == 'GET':
category = request.args.get('category')
return jsonify(getNews(category))
if __name__ == '__main__':
app.run(debug=True)