|
|
@ -1,6 +1,8 @@
|
|
|
|
import logging
|
|
|
|
import logging
|
|
|
|
logging.basicConfig(format='%(asctime)s : %(levelname)s : %(message)s', level=logging.INFO)
|
|
|
|
logging.basicConfig(format='%(asctime)s : %(levelname)s : %(message)s', level=logging.INFO)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
from datetime import datetime
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Flask application to serve the web pages
|
|
|
|
# Flask application to serve the web pages
|
|
|
|
from flask import Flask, request, redirect, url_for, jsonify
|
|
|
|
from flask import Flask, request, redirect, url_for, jsonify
|
|
|
@ -48,7 +50,6 @@ class PrefixMiddleware(object):
|
|
|
|
# create flask application
|
|
|
|
# create flask application
|
|
|
|
app = Flask(__name__)
|
|
|
|
app = Flask(__name__)
|
|
|
|
CORS(app)
|
|
|
|
CORS(app)
|
|
|
|
# MakoTemplates(app)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Url prefix for the soupboat
|
|
|
|
# Url prefix for the soupboat
|
|
|
@ -74,7 +75,7 @@ def add_pad(link, title, overview, categories, date):
|
|
|
|
text = page.text()
|
|
|
|
text = page.text()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
new_row = f'|-\n| {link} || {title} || {overview} || {categories} || {date}\n|-\n' + '|}'
|
|
|
|
new_row = f'|-\n| {link} || {title} || {overview} || {categories} || {date} \n|-\n' + '|}'
|
|
|
|
|
|
|
|
|
|
|
|
text = text.replace('|}', new_row)
|
|
|
|
text = text.replace('|}', new_row)
|
|
|
|
|
|
|
|
|
|
|
@ -84,10 +85,10 @@ def add_pad(link, title, overview, categories, date):
|
|
|
|
def get_pads():
|
|
|
|
def get_pads():
|
|
|
|
|
|
|
|
|
|
|
|
site = mwclient.Site('pzwiki.wdka.nl', path='/mw-mediadesign/')
|
|
|
|
site = mwclient.Site('pzwiki.wdka.nl', path='/mw-mediadesign/')
|
|
|
|
|
|
|
|
|
|
|
|
site.login(
|
|
|
|
site.login(
|
|
|
|
username=os.environ.get('MW_BOT'),
|
|
|
|
username=os.environ.get('MW_BOT'),
|
|
|
|
password=os.environ.get('MW_KEY')
|
|
|
|
password=os.environ.get('MW_KEY'),
|
|
|
|
|
|
|
|
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
html = site.api('parse', prop='text', page=padliography)
|
|
|
|
html = site.api('parse', prop='text', page=padliography)
|
|
|
@ -95,7 +96,7 @@ def get_pads():
|
|
|
|
|
|
|
|
|
|
|
|
headers = [header.text.lower().strip() for header in table.find_all('th')]
|
|
|
|
headers = [header.text.lower().strip() for header in table.find_all('th')]
|
|
|
|
pads = [
|
|
|
|
pads = [
|
|
|
|
{headers[i]: cell.text for i, cell in enumerate(row.find_all('td'))}
|
|
|
|
{headers[i]: cell.text.rstrip('\n') for i, cell in enumerate(row.find_all('td'))}
|
|
|
|
for row in table.find_all('tr')]
|
|
|
|
for row in table.find_all('tr')]
|
|
|
|
pads = [ pad for pad in pads if pad != {}]
|
|
|
|
pads = [ pad for pad in pads if pad != {}]
|
|
|
|
return pads
|
|
|
|
return pads
|
|
|
@ -119,6 +120,8 @@ def home():
|
|
|
|
categories = request.json.get('categories', '')
|
|
|
|
categories = request.json.get('categories', '')
|
|
|
|
date = request.json.get('date', None)
|
|
|
|
date = request.json.get('date', None)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
date = datetime.strftime(datetime.strptime(date, 'yyyy-mm-dd'), 'dd-mm-yyyy')
|
|
|
|
|
|
|
|
|
|
|
|
add_pad(link, title, overview, categories, date)
|
|
|
|
add_pad(link, title, overview, categories, date)
|
|
|
|
redirect(url_for('home'))
|
|
|
|
redirect(url_for('home'))
|
|
|
|
|
|
|
|
|
|
|
|