#๐Ÿ”’ Creating a button depending on the day/time value entered by user.

77 messages ยท Page 1 of 1 (latest)

lilac lake
#

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.

sharp wraithBOT
#

@lilac lake

Python help channel opened

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.

iron pier
#

dunno what it would mean to "redirect to an HTML template"

#

do you mean "redirect to a page which you generate via a template"?

lilac lake
lilac lake
iron pier
#

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 ..."

lilac lake
#

do I have to create a html template for each time slot before the button would be created?

iron pier
#

I think you just want to create an html page based on the given date and time

iron pier
lilac lake
iron pier
#

ah

lilac lake
#

I use both in the same context

#

since I assumed they are the ame

#

same*

iron pier
#

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.

lilac lake
iron pier
#

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

lilac lake
#

except for base

iron pier
#

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]]

lilac lake
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

lilac lake
#

like this

#

but I wanted to link it to my python files

#

rather than keep it in the html file

iron pier
#

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

lilac lake
#

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

iron pier
#

ok?

#

should be doable

lilac lake
#

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

iron pier
#

that, I don't understand

lilac lake
#

but I couldn't find anything that would allow me to do that

iron pier
#

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]

lilac lake
#

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

iron pier
#

I'd say "it's done in Javascript which I don't like"

lilac lake
#

i thought JS and html were different?

iron pier
#

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

lilac lake
#

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)

iron pier
#

yes you've already said that

lilac lake
#

I can add the button myself, I don't expect python help to code for me

iron pier
#

and I understand it

lilac lake
iron pier
#

of course it's possible

lilac lake
#

are there any examples you could provide

#

because I couldn't find any

iron pier
#

not offhand but there must be hundreds on the web

lilac lake
#

or just methods to do so using python flask

lilac lake
iron pier
#

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.

sharp wraithBOT
#
Python help channel closed

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.