full-feed-financial-times/web.py
2020-04-20 01:16:44 +02:00

58 lines
1.3 KiB
Python

#!/usr/bin/python
#
import main
from flask import Flask,request
app = Flask(__name__)
def run_flask(host,port):
app = Flask(host=host, port=port)
app.run()
def getFeeds(db):
db = getDb()
cursor = db.cursor()
cusror.execute('''
SELECT name FROM feeds
''')
feeds = cursor.fetchall()
cursor.close()
return feeds
@app.route('/')
def list():
feeds = getFeeds()
a = "<html><body><p>Header</p><br><table><tr><td>Feeds</td></tr>"
for i in feeds:
a+= "<tr><td><a href='/configure?feed={}'>{}</a></td></tr>".format(i,i)
a+= "</table></body></html>"
return a
@app.route('/configure', methods = ['GET','POST'])
def configure(feed_name):
db = getDb()
feed = lf(db, feed_name)
if request.method == 'POST':
for k,v in request.form.items():
feed.query_db(k,v)
config_list = (
"url",
"password",
"username",
"selector",
"selector_login_user",
"selector_login_pass",
"selector_login_verify",
"selector_login_verify_url",
"selector_login_url")
a = '<html><body><form>'
for i in config_list:
a += '''
<label for="{}">{}</label><br>
<input type="text" value="{}" id="{}">
'''.format(i,i,feed.query_db(i),i)
a += "</form></body></html>"