Prepare worldclock, no trailing / for blueprint roots
All checks were successful
continuous-integration/drone/push Build is passing

If specifying a blueprint with route "/", this will result
in flask redirecting to a request to `http://example.com/blueprint`
to `http://example.com/blueprint/`. This we don't want.
This commit is contained in:
Armin Friedl 2020-09-14 21:13:25 +02:00
parent 89889e947a
commit 19c9e720e7
Signed by: armin
GPG key ID: 48C726EEE7FBCBC8
12 changed files with 60 additions and 3 deletions

View file

@ -4,7 +4,7 @@ from . import app
from . import forms
from .countdown import Cache
@app.route('/', methods=['GET', 'POST'])
@app.route('', methods=['GET', 'POST'])
def create():
session.permanent = True
if not session.get('created_countdowns'):

View file

@ -9,3 +9,6 @@ import views
from countdown import app as countdown
app.register_blueprint(countdown, url_prefix="/countdown")
from worldclock import app as worldclock
app.register_blueprint(worldclock, url_prefix="/worldclock")

View file

@ -19,3 +19,10 @@ PATCH http://localhost:5000/countdown/api/v1/reset/:id
# GET
GET http://localhost:5000/countdown/api/v1/:id
# GET
GET http://localhost:5000/worldclock
# POST
POST http://localhost:5000/worldclock

View file

@ -4,9 +4,12 @@ const path = require('path');
module.exports = {
entry: {
netclock: './js/netclock.js',
countdown_create: './countdown/templates/countdown/create.js',
countdown_view: './countdown/templates/countdown/view.js',
countdown_created: './countdown/templates/countdown/created.js'
countdown_created: './countdown/templates/countdown/created.js',
worldclock_create: './worldclock/templates/worldclock/create.js'
},
plugins: [
new CleanWebpackPlugin()

5
worldclock/__init__.py Normal file
View file

@ -0,0 +1,5 @@
from flask import Blueprint
app = Blueprint('worldclock', __name__, template_folder='templates')
from . import views
from . import api

0
worldclock/api.py Normal file
View file

0
worldclock/forms.py Normal file
View file

View file

@ -0,0 +1,27 @@
{% extends "base.html" %}
{% block title %}Worldclock{% endblock title %}
{% block body %}
<div class="center">
<form method="POST" action="{{ url_for('worldclock.create') }}">
{{ form.csrf_token }}
<div id="main-clock">
<div id="main-clock-hours"></div>
<div id="main-clock-minutes"></div>
<div id="main-clock-timezone"></div>
</div>
<div id="sub-clocks">
<div class="sub-clock">
<div class="sub-clock-timezone"></div>
</div>
</div>
<input id="btn-create" type="submit" value="Go">
</form>
</div>
{% endblock body %}
{% block scripts %}
<script src="{{ url_for('static', filename='dist/worldclock_create.bundle.js') }}"></script>
{% endblock scripts %}

View file

@ -0,0 +1 @@
import './create.scss';

11
worldclock/views.py Normal file
View file

@ -0,0 +1,11 @@
from flask import render_template, request, flash, redirect, url_for, session
from . import app
@app.route('', methods=['GET'])
def create_get():
return "Bye"
@app.route('', methods=['POST'])
def create_post():
return "Hello"

0
worldclock/worldclock.py Normal file
View file