2020-04-16 08:33:46 +00:00
|
|
|
#!/usr/bin/python
|
|
|
|
#
|
|
|
|
|
|
|
|
import main
|
|
|
|
|
|
|
|
from flask import Flask,request
|
|
|
|
app = Flask(__name__)
|
|
|
|
|
|
|
|
|
2020-04-19 23:16:44 +00:00
|
|
|
def run_flask(host,port):
|
|
|
|
app = Flask(host=host, port=port)
|
|
|
|
app.run()
|
2020-04-16 08:33:46 +00:00
|
|
|
|
|
|
|
def getFeeds(db):
|
|
|
|
db = getDb()
|
|
|
|
cursor = db.cursor()
|
|
|
|
cusror.execute('''
|
|
|
|
SELECT name FROM feeds
|
|
|
|
''')
|
|
|
|
feeds = cursor.fetchall()
|
|
|
|
cursor.close()
|
|
|
|
return feeds
|
|
|
|
|
|
|
|
@app.route('/')
|
2020-04-19 23:16:44 +00:00
|
|
|
def list():
|
2020-04-16 08:33:46 +00:00
|
|
|
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)
|
2020-04-19 23:16:44 +00:00
|
|
|
a += "</form></body></html>"
|