forked from fredzannarbor/newsstand
/
index.py
37 lines (32 loc) · 1.13 KB
/
index.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
# _ __ __ __
# / | / /__ _ ____________/ /_____ _____ ____/ /
# / |/ / _ \ | /| / / ___/ ___/ __/ __ `/ __ \/ __ /
# / /| / __/ |/ |/ (__ |__ ) /_/ /_/ / / / / /_/ /
# /_/ |_/\___/|__/|__/____/____/\__/\__,_/_/ /_/\__,_/
# Description: Provides the latest news from a multitude of news sources.
# GitHub Repository: Newsstand (github.com/cryptopelago/newsstand)
# License: Unlicense (unlicense.org)
# Load libraries
import requests
import urllib
import os
import json
import yaml
from flask import Flask, request
from two1.wallet import Wallet
from two1.bitserv.flask import Payment
# Init Flask, Wallet and Payment
app = Flask(__name__)
wallet = Wallet()
payment = Payment(app, wallet)
# Add 402
@app.route('/news')
@payment.required(900)
def lookup_string():
source = request.args.get('source')
key = os.environ.get('KEY')
url = requests.get('https://newsapi.org/v1/articles?source='+source+'&sortBy=latest&apiKey='+key)
return url.text
# Init Host
if __name__=='__main__':
app.run(host='::', port='10125')