Prepare worldclock, no trailing / for blueprint roots
All checks were successful
continuous-integration/drone/push Build is passing
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:
parent
89889e947a
commit
19c9e720e7
12 changed files with 60 additions and 3 deletions
|
@ -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'):
|
||||
|
|
|
@ -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")
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
5
worldclock/__init__.py
Normal 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
0
worldclock/api.py
Normal file
0
worldclock/forms.py
Normal file
0
worldclock/forms.py
Normal file
27
worldclock/templates/worldclock/create.html
Normal file
27
worldclock/templates/worldclock/create.html
Normal 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 %}
|
1
worldclock/templates/worldclock/create.js
Normal file
1
worldclock/templates/worldclock/create.js
Normal file
|
@ -0,0 +1 @@
|
|||
import './create.scss';
|
0
worldclock/templates/worldclock/create.scss
Normal file
0
worldclock/templates/worldclock/create.scss
Normal file
11
worldclock/views.py
Normal file
11
worldclock/views.py
Normal 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
0
worldclock/worldclock.py
Normal file
Loading…
Reference in a new issue