Skip to content

Commit

Permalink
refactor: init
Browse files Browse the repository at this point in the history
  • Loading branch information
iguridi committed Apr 28, 2020
1 parent 082dd63 commit 24b6c12
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,6 @@ This project consists of a web page that allows anyone to download an automatica

Currently running [here](https://pptmisa.herokuapp.com/)

Tested and deployed with *Python 3.7*
Tested and deployed with _Python 3.7_

Run locally with `python3 init.py`
13 changes: 7 additions & 6 deletions app/init.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@

from flask import Flask, render_template, request, send_from_directory, current_app

from maker import scrapper, ppt_maker

flask_app = Flask(__name__)
# app.config.from_object('config')
flask_app.config['DEBUG'] = True

BASE_URL = 'http://www.eucaristiadiaria.cl/'
Expand All @@ -23,7 +24,6 @@

@flask_app.route('/download-ppt', methods=['GET', 'POST'])
def download():
from maker import scrapper, ppt_maker
folder = 'maker'
directory = os.path.dirname(__file__)
base_ppt = os.path.join(directory, folder, BASE_PPT)
Expand All @@ -32,18 +32,19 @@ def download():
title = request.args['title']
date = request.args['date']
date = datetime.strptime(date, '%Y-%m-%d')
url = BASE_URL + 'dia_cal.php?fecha=' + str(date)
date = ' '.join([str(date.day), month_name(date.month), str(date.year)])
url = f'{BASE_URL}dia_cal.php?fecha={date}'
date_formatted = f'{date.day} {month_name(date.month)} {date.year}'
addrs, readings = scrapper.run(url)

ppt_maker.Maker(base_ppt, output_ppt, addrs, readings, title, date)
ppt_maker.Maker(base_ppt, output_ppt, addrs, readings, title,
date_formatted)

path = os.path.join(current_app.root_path, folder)

return send_from_directory(directory=path,
filename=OUTPUT_PPT,
as_attachment=True,
attachment_filename=date + '.pptx')
attachment_filename=date_formatted + '.pptx')


def month_name(month_number):
Expand Down

0 comments on commit 24b6c12

Please sign in to comment.