Using flask I want to be able to allow the user to enter the day/time in which they have a meeting and then once entered it will automatically create a html template that I can redirect the user to, however I've only seen the ability to redirect to html templates that are preexisting.
#๐ Creating a button depending on the day/time value entered by user.
77 messages ยท Page 1 of 1 (latest)
@lilac lake
Remember to:
- Ask your Python question, not if you can ask or if there's an expert who can help.
- Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
- Explain what you expect to happen and what actually happens.
:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.
Closes after a period of inactivity, or when you send !close.
dunno what it would mean to "redirect to an HTML template"
do you mean "redirect to a page which you generate via a template"?
as in return redirect(url_for('x'))
ig but I want the template to be created when the slot is added to the timetable
well I don't use flask, but that sounds like what I said
you create templates; your server doesn't.
That's like saying "I want my server to create python code that ..."
as in when I enter a day and time it will create a html template in the time slot and a button will appear within the <td>
do I have to create a html template for each time slot before the button would be created?
I think you just want to create an html page based on the given date and time
I don't understand that question at all. I suspect you and I have very different definitions for the word "template", and I don't know what yours is.
what is the difference between a html page and a template
ah
a "template" has spots in it where your server can fill in different strings, depending on variables
a page is just what your browser knows how to render
templates use languages like jinka or mako
I would humbly suggest that you are misusing the word "template", and will confuse everyone you speak to, unless you straighten out.
in the flask tutorial I watched all of these are categorised as templates tho?
I have no idea what tutorial you watched, nor how they use, or misuse, terminology
it's possible that those files are indeed templates, I can't tell just by looking at their names.
templates typically have stuff like {{ this }} in them
wheras HTML doesn't
I have that in all of my html - {% extends "base.html" %} {% block title %}Schedule{% endblock %} {% block content
%}
except for base
ok that sure looks like a template
but you created those; your flask server didn't
[[and those templates look like django's template language; I'd be surprised if they worked in flask]]
I see what you mean now, is it not possible to write code to create a template like I mentioned here @iron pier
no idea what you mean
anyone can create a template at any time; all you need is a text editor
but I doubt that's what you were asking
like this
but I wanted to link it to my python files
rather than keep it in the html file
that looks like some JS code, which I'm too lazy to study carefully
what does it have to do with your question?
if you want to put JS into your template, go ahead
it should work fine
when I enter a time and day here I want it to add a button to the corresponding table slot which will then redirect the user to a separate html file
I was wondering if I had to manually create each html file or if once the button I have put is in the table there is a method to create a html file
this is my question ^ @iron pier
I don't expect someone to code the function of adding a button
that, I don't understand
but I couldn't find anything that would allow me to do that
I can think of two broad ways to add a button:
- reload the page entirely, and have the server deliver a new page that is like the old page, except with the button where you want it
- write some JS that just adds the button to the existing page
[that timetable looks pretty slick btw]
https://paste.pythondiscord.com/4CSQ
If you want to skim read this paste bin, this html file allows you to create a button once day/time entered and creates a html file but it's all done in html which I don't like
I'd say "it's done in Javascript which I don't like"
i thought JS and html were different?
they are
so the question is: what role do you want your web server to play in this
I notice there is no "add-slot-btn" yet
When the day/time inputted by a user I want to create a button (which I can do myself) in the corresponding table slot and once this table slot is pressed it will create a html file for me e.g.(monday_13:00)
yes you've already said that
I can add the button myself, I don't expect python help to code for me
and I understand it
so is it possible or no?
of course it's possible
not offhand but there must be hundreds on the web
or just methods to do so using python flask
already looked which is why I'm asking here
maybe add an event listener that "listens to" both the day and time select thingies; when they both have a value, have the event listener add the button.
that way you're doing it entirely in javascript. That's not necessarily better than having flask do it; it's just one way
another way: have those select thingies be part of a form, which does a POST to your flask server; have it return another page, just like this one, except with the new button in the right place.
This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.