From ea00488f3218ffc5e3186f4aa81090c54ed3ec17 Mon Sep 17 00:00:00 2001 From: "Sachin S. Kamath" <sskamath96@gmail.com> Date: Sat, 30 Sep 2017 14:37:16 +0530 Subject: [PATCH] Refactor boilerplate template Signed-off-by: Sachin S. Kamath <sskamath96@gmail.com> --- project/__init__.py | 9 ---- project/__init__.pyc | Bin 489 -> 0 bytes project/controllers/__init__.py | 4 -- project/controllers/printer.py | 26 ---------- project/models/Printer.py | 11 ----- project/models/__init__.py | 0 project/static/css/style.css | 71 --------------------------- project/templates/layout/layout.html | 22 --------- project/templates/printer/index.html | 8 --- project/templates/printer/print.html | 10 ---- runserver.py | 0 11 files changed, 161 deletions(-) delete mode 100644 project/__init__.py delete mode 100644 project/__init__.pyc delete mode 100644 project/controllers/__init__.py delete mode 100644 project/controllers/printer.py delete mode 100644 project/models/Printer.py delete mode 100644 project/models/__init__.py delete mode 100644 project/static/css/style.css delete mode 100644 project/templates/layout/layout.html delete mode 100644 project/templates/printer/index.html delete mode 100644 project/templates/printer/print.html mode change 100644 => 100755 runserver.py diff --git a/project/__init__.py b/project/__init__.py deleted file mode 100644 index e73a1ec..0000000 --- a/project/__init__.py +++ /dev/null @@ -1,9 +0,0 @@ -# -*- coding: utf-8 -*- -__version__ = '0.1' -from flask import Flask -from flask_debugtoolbar import DebugToolbarExtension -app = Flask('project') -app.config['SECRET_KEY'] = 'random' -app.debug = True -toolbar = DebugToolbarExtension(app) -from project.controllers import * diff --git a/project/__init__.pyc b/project/__init__.pyc deleted file mode 100644 index b3e858bb2e0baa73ac56f54c1b8df5e3b637a185..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 489 zcmZSn%*!Pib3QVe0ScHI7#JKF7#NC^7#J8*7#N}$7*ZG+QkWQW7#VVz7^0XM7(sky zh8$*wTo#5X76!&tCWaIihGs^FC{~6PR)$nohAcLQ6gCE%RCW+2o`WHk1;hZU-~^k- z&XB{!5R$^d5UjxovI}IXfu3RJ|NsC0YcMh}FqE(|Ffh2~Bo=2wxS|XU3@)ijrRgF0 z`8i36MXnVksd>ej`FSPm3=9kfMfq8&$t5Lh3=9lKiFqmcxg}f-3=F}p&Oxpr@!qbH z5JNx)Yx!w#gUkmJ@$qG;MIb}s<H7c&f$R$cg+qxD0|Nt?8=nHQwFF{o5XgiQkYf`I z3c$7{=jWwmrkAiVFffD^m8OD?f#?9a3#zR|7~w{}<ovvnqWqkk)S_YykW~nx*pz{R zK|douH&wqlJ25x0BtswSv10v<{FMA6{p9?VRG654e0*kJW=VX!UO{CE2Ll6xO>TZl dX-=vg6DUCW7#JAX7zG#w7<m|Z895nw7y-2BZCn5V diff --git a/project/controllers/__init__.py b/project/controllers/__init__.py deleted file mode 100644 index 844f750..0000000 --- a/project/controllers/__init__.py +++ /dev/null @@ -1,4 +0,0 @@ -import os -import glob -__all__ = [os.path.basename( - f)[:-3] for f in glob.glob(os.path.dirname(__file__) + "/*.py")] diff --git a/project/controllers/printer.py b/project/controllers/printer.py deleted file mode 100644 index 0da47df..0000000 --- a/project/controllers/printer.py +++ /dev/null @@ -1,26 +0,0 @@ -# -*- coding: utf-8 -*- -from project import app -from flask import render_template, request -from flask_wtf import FlaskForm -from wtforms import StringField -from wtforms.validators import DataRequired - - -class CreateForm(FlaskForm): - text = StringField('name', validators=[DataRequired()]) - - -@app.route('/') -def start(): - return render_template('printer/index.html') - - -@app.route('/print', methods=['GET', 'POST']) -def printer(): - form = CreateForm(request.form) - if request.method == 'POST' and form.validate(): - from project.models.Printer import Printer - printer = Printer() - printer.show_string(form.text.data) - return render_template('printer/index.html') - return render_template('printer/print.html', form=form) diff --git a/project/models/Printer.py b/project/models/Printer.py deleted file mode 100644 index 54ff974..0000000 --- a/project/models/Printer.py +++ /dev/null @@ -1,11 +0,0 @@ -# -*- coding: utf-8 -*- -from flask import flash - - -class Printer(object): - - def show_string(self, text): - if text == '': - flash("You didn't enter any text to flash") - else: - flash(text + "!!!") diff --git a/project/models/__init__.py b/project/models/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/project/static/css/style.css b/project/static/css/style.css deleted file mode 100644 index dcbbde0..0000000 --- a/project/static/css/style.css +++ /dev/null @@ -1,71 +0,0 @@ -body { - font-family: sans-serif; - background: #eee; -} - -a,h1,h2 { - color: #377BA8; -} - -h1,h2 { - font-family: 'Georgia', serif; - margin: 0; -} - -h1 { - border-bottom: 2px solid #eee; -} - -h2 { - font-size: 1.2em; -} - -.page { - margin: 2em auto; - width: 35em; - border: 5px solid #ccc; - padding: 0.8em; - background: white; -} - -.entries { - list-style: none; - margin: 0; - padding: 0; -} - -.entries li { - margin: 0.8em 1.2em; -} - -.entries li h2 { - margin-left: -1em; -} - -.add-entry { - font-size: 0.9em; - border-bottom: 1px solid #ccc; -} - -.add-entry dl { - font-weight: bold; -} - -.metanav { - text-align: right; - font-size: 0.8em; - padding: 0.3em; - margin-bottom: 1em; - background: #fafafa; -} - -.flash { - background: #CEE5F5; - padding: 0.5em; - border: 1px solid #AACBE2; -} - -.error { - background: #F0D6D6; - padding: 0.5em; -} \ No newline at end of file diff --git a/project/templates/layout/layout.html b/project/templates/layout/layout.html deleted file mode 100644 index a026d6c..0000000 --- a/project/templates/layout/layout.html +++ /dev/null @@ -1,22 +0,0 @@ -<!doctype html> - <head> - <link rel="stylesheet" type="text/css" href="{{ url_for('static', filename='css/style.css') }}"> - <title>Flask-MVC</title> - </head> - <body> - <a style="text-align:center" href="{{ url_for('start') }}">Home</a> - <a style="text-align:center" href="http://salimane.com">About</a> - <div class="page"> - <h1>Flask MVC Boilerplate</h1> - {% for message in get_flashed_messages() %} - <div class="flash">{{ message }}</div> - {% endfor %} - {% macro render_error(field) %} - {% if field.errors %} - {% for error in field.errors %}<span class='error'>{{ error }}</span>{% endfor %} - {% endif %} - {% endmacro %} - {% block body %}{% endblock %} - </div> - </body> -</html> diff --git a/project/templates/printer/index.html b/project/templates/printer/index.html deleted file mode 100644 index 00e9c5e..0000000 --- a/project/templates/printer/index.html +++ /dev/null @@ -1,8 +0,0 @@ -{% extends "layout/layout.html" %} -{% block body %} - <ul> - <p> - <a href="{{ url_for('printer') }}">Click here to print!</a> - </p> - </ul> -{% endblock %} diff --git a/project/templates/printer/print.html b/project/templates/printer/print.html deleted file mode 100644 index 6053f54..0000000 --- a/project/templates/printer/print.html +++ /dev/null @@ -1,10 +0,0 @@ -{% extends "layout/layout.html" %} -{% block body %} - <form action="{{ url_for('printer') }}" method="post"> - {{ form.csrf_token }} - <dl> - <dd>{{ form.text.label }} {{ form.text(size=20) }} {{ render_error(form.text) }}</dd> - <dd><input type="submit" value="Flash"/></dd> - </dl> - </form> -{% endblock %} diff --git a/runserver.py b/runserver.py old mode 100644 new mode 100755 -- GitLab