#web-development

2 messages ยท Page 204 of 1

heavy ferry
#

nvm got it

#

actually nvm i do not got it

#

i centered it horizontally but not vertically

inland oak
#

universal centerer

split snow
#

does someone know about postgres here?

dusty steeple
#

I know extremely limited postgres..., but their discord is pretty cool/active imo.

dusty steeple
dusty steeple
verbal wind
#

hey everyone, hope you all are fine I am having some trouble with Elastic Search and Django, so when i make some change in data stored in models the respective change is not reflected in the elastic search query until I manually update the concerned model by self assinging any of the field of that model through python manage.py shell, is there any better way to reflect those chenges?

native tide
#

Hey

#

In my Django project i have a admin page where i can manage all users:

#

How can i display a formated string, and not UserObject(x) in the "title"?

verbal wind
#

go to respective model and add an str method for the same

#

in your case u have to overwrite the Users model's str method

barren sedge
#

Can someone help me with this error? I've checked my python39/scripts file, it successfully installed django-admin.exe there, but why I can't use it thru cmd?

verbal wind
#

add the path as mentioned in error

barren sedge
verbal wind
#

C:\Users......something

#

add that entire directory to ur path

#

i think it is done through enviroment variables in windows

#

but if u want to avoid adding path maybe u can try using a virtual environment

barren sedge
#

like this?

verbal wind
#

noo

#

just check

#

on google

#

how to add a directory to path

#

on windows

#

u have add that complete directory starting from C:Users.......Scripts to ur path

barren sedge
verbal wind
#

yes this thing

barren sedge
#

but when I tried to run the command window they suggest, nothing happens

verbal wind
#

there is a gui way of doing it

#

i dont remember

barren sedge
verbal wind
#

open cmd as admin i guess

#

but not sure

#

do verify with some windows user

barren sedge
# verbal wind do verify with some windows user

Ohh it works rn, but only in current active session. Then I read that you can make it permanent using setx, but a user gave warning about using setx like I show from the pic I gave, what does it mean?

verbal wind
#

dont use this

#

just try to set the path through the gui or with admin privleges and u will be good to go

#

if u are not comfortable with setting paths

verbal wind
#

u should try using virtual environmant

verbal wind
barren sedge
verbal wind
#

yessss

#

thiss

#

there are two of these

#

add the one in which u see ur python path added

barren sedge
#

omg it works bro, jsdfjsadfbasjdfa

TforThankyousomuchhhhh

verbal wind
#

no problem

native tide
#
@app.route("/addviolation", methods=['post'])
def addviolation():
    id = request.values.get('id')
    data = request.get_json()
    print(data)
    y = json.loads(str(id))
    reason = request.values.get('reason')
    x = json.loads(str(reason))
    print(y)
    print(x)
    return str(200)```
its supposed to receive JSON from a Roblox game, but it gives me this error.
`json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)`
verbal wind
#

print(str(id))

#

before data

#

maybe its empty

#

or maybe reason variable is empty

#

print both before json.loads

native tide
#

its None

verbal wind
#

both of them?

native tide
#

yeah

verbal wind
#

so it will through this

#

i guess if its None it should through some error related to None type

#

i might be ""

native tide
#

wdym

#

what is being send is {"id":1643220705,"reason":"kankdfsfu"}

verbal wind
#

i mean what u sent to loads?

#

what is the value of str(id)

#

and what is the value of str(reason)

#

when u send it

native tide
#

thats remnant of a previous experiment

verbal wind
#

so if u send str(none) or "" to json.loads

#

u will keep getting that error

#

just make sure before u pass value to json.loads - it has something other than none and empty string

native tide
#

its None

#

it doesnt return anything

verbal wind
#

yea

#

so u'll keep getting that error

#

just put that in an if else statement

#

to use json.loads only when those value are not none

autumn veldt
#

hi how can i send a file to my flask webserver using requests ?

#

and than the webserver will download it

autumn veldt
#

almost

#

i dont want to do it from gui

#

like in html

#

i need to write an app that sends the files to a webserver

jovial mortar
#

That's what that is

golden bone
haughty isle
autumn veldt
#

why its not working

#

can you help me ? @woven oak

woven oak
#

How can I help you? @autumn veldt

#

?

autumn veldt
#

even with full path its not working

woven oak
#

Could you show me the full path?

autumn veldt
#

C:\Users\oriko\PycharmProjects\python-p\raspi-zero\img.png

haughty isle
#

!rule 9

lavish prismBOT
#

9. Do not offer or ask for paid work of any kind.

haughty isle
#

Also ES6 isn't current, it's very old

woven oak
autumn veldt
#

yes

#

thats what i wrote

woven oak
#

Can you show me the code snippet?

autumn veldt
#

look:
code:

@app.route('/get/<path>')
def get(path=None):
    if path == None:
        return "{'msg':'please enter a path'}"
    else:
        for file in [val for sublist in [[os.path.join(i[0], j) for j in i[2]] for i in os.walk('./')] for val in sublist]:
            if path == file[2:]:
                if str(path).endswith((".png", ".jpg", ".jpeg", ".webp", "svg", ".ico", ".apng", ".avif")):
                    path = os.path.abspath(path)
                    return render_template('img.html', img=path)
                else:
                    return render_template('content.html', text=open(path, "r+").read())

        return "{'msg':'please enter a valid path'}"

html:

<!DOCTYPE html>
<html>
<head>
    <title>{{ img }}</title>
</head>
<body>
    <img src="{{ img }}" alt="img">
</body>
</html>
woven oak
#

Have you ever tried like this?

autumn veldt
#

wdym ?

woven oak
autumn veldt
#

umm no

#

il try

#

nope

#

not working

woven oak
#

?

#

Really?

autumn veldt
#

yes

woven oak
#

Show me screenshot

autumn veldt
#

see ?

#

anyway i gota go

tawny parcel
#

thats the worst screenshot i have ever seen

terse vapor
#

tuff

calm plume
#

use relative paths

split snow
#

does someone know about postgres here? can someone help me?

verbal wind
#

your question must be in databases channel though i guess

split snow
#

i have a jsonb column name document in Postgres however

when i query select * from database it returns like this one

id : 1, document : {"data": 1}

how to return like t his one

id: 1, "data": 1

removing the document:{}
Thanks

hushed vortex
#

please help
i am making a personal website and it has some issues
on my pc it looks like this

#

but on my ipad it looks like this

#

how can i fix this?

inland oak
#

starting with reset technique should be good

lavish prismBOT
#

:incoming_envelope: :ok_hand: applied mute to @inland oak until <t:1638858808:f> (9 minutes and 58 seconds) (reason: newlines rule: sent 132 newlines in 10s).

hushed vortex
#

o no

#

you can dm me

prime carbon
#

!unmute 370435997974134785

lavish prismBOT
#

:incoming_envelope: :ok_hand: pardoned infraction mute for @inland oak.

prime carbon
#

!paste

lavish prismBOT
#

Pasting large amounts of code

If your code is too long to fit in a codeblock in discord, you can paste your code here:
https://paste.pythondiscord.com/

After pasting your code, save it by clicking the floppy disk icon in the top right, or by typing ctrl + S. After doing that, the URL should change. Copy the URL and post it here so others can see it.

prime carbon
#

use our pasting service for long blocks of text

inland oak
#

well, I'll drop copy here then

#

this is one out of two ways to reset CSS between different browsers

#

@hushed vortex apply it somewhere globally in the root of your project

#

for example in vue.js I have it applied...

#

App.vue

<template>
  <router-view />
</template>

<style lang="scss">
@import "@/assets/style/_reset";
</style>

right at the almost most global scope, in the beginning of my style code

#

if u aren't using vue.js...
just use css importing and have it in header

#

@hushed vortex importing looks like this in regular HTML5 code

<!DOCTYPE html>
<head>
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width,initial-scale=1.0">
  <link rel="stylesheet" href="css/reset.css">
</head>

<body>

</body>

</html>
hushed vortex
#

im using basic html

#

and some css

inland oak
#

plus use those meta tags too

icy ether
#

anyone knows what pusher is ?
I need help about channels

inland oak
#

the viewport one helps for better mobile compatibility too

hushed vortex
#

@inland oak this is the file i use for the layout on all my pages

<!-- this file is for template inheritance-->

<html>
    <head>
        <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3" crossorigin="anonymous">    
    </head>
    <body>
        <style>
            body {background-color: #171717;}
        </style>
         <meta name="apple-mobile-web-app-capable" content="yes">   
        <div class="container">
            {% block content %}{% endblock %}
        </div>
    </body> 
</html>```
inland oak
#
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width,initial-scale=1.0">
<link rel="stylesheet" href="reset.css">

with adding the reset.css file with mentioned stuff to your project root

hushed vortex
#

good?

inland oak
hushed vortex
#

hm?

#

ah

#

now it does this

#

@inland oak

inland oak
hushed vortex
#
<!-- this file is for template inheritance-->
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width,initial-scale=1.0">
    <link rel="stylesheet" href="css/reset.css">
</head>
<html>
    <head>
        <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3" crossorigin="anonymous">    
    </head>
    <body>
        <style>
            body {background-color: #171717;}
        </style>
         <meta name="apple-mobile-web-app-capable" content="yes">   
        <div class="container">
            {% block content %}{% endblock %}
        </div>
    </body> 
</html>```
inland oak
#

just verify in your browser, if the styles were applied

#

if not, fix it

#

use Chrome dev tools to check applued styles
and console to see if there was importing error

hushed vortex
inland oak
#

I would highly recommend to read Head First CSS 2nd edition book
and CSS the missing manual 4th edition

hushed vortex
#

ok

native tide
#

both django and flask currently use multi-threading

#

each request is processed in a new thread

restive copper
#

Hey,
I need some help with django. I am very new to this and I just want to link the database to the form tag in html, so I can input the data and save in the model.

#

is there anyone who can spare 5 mins?

minor spire
#

how much python should i know before learning flask?

lost frost
#

hi all

I am defining the slack_events_adapter in main, so of course the decorators are not resolvable,
any advise anyone

I am a self tough programmer ๐Ÿ™‚ so be nice ๐Ÿ˜›

app = Flask(__name__)

# Create an event listener for "reaction_added" events and print the emoji name
@slack_events_adapter.on("reaction_added")
def reaction_added(event_data):
    print("rection_added")


@slack_events_adapter.on("message")
def reaction_added(event_data):
    print("message")

def main():
    """ Main function

    Returns:
        None
    """
    arguments = args()
    my_logger = logger(arguments.debug)
    my_logger.info('Starting slack_bot')
    variables = get_vars(arguments, my_logger)
    slack_events_adapter = SlackEventAdapter(variables[0], "/slack/events", app)


    app.run(host=arguments.flask_host, port=arguments.flask_port, debug=arguments.flask_debug)
dusk portal
#

i basically am making a quiz type application using django the problem im facing is i made a next button
so 1 question paper contains 20 question
each question has a img file question
4 options a,b,c,d
n one answer (radio button)
(same as google forms but question in img format)
the problem is for the next question feature i implemented js , it's working fine but the question is how can i render/fetch my objects of db to js

#

the first object is loading from the html loop (rendering from the db) so how can i load more from db

#

how can i retrive post from db to js ?

native tide
#

how can i make a search code for this xpath

haughty isle
restive copper
#

hey, graingert, i need some help in django database, can you help?

#

it will only take like 5 mins, im very new to django and stuff

haughty isle
restive copper
#

actually i need someone to see my screen and guide, im a little unsure on how to ask the question

#

in short i am having trouble in linking my database to the form input in html

native tide
lost frost
weak matrix
#

Idk if this is the right place to ask since its not really web development but

#

Im trying to get into webscraping using beautifulSoup and requests. So I've gotten the htmlcode for a website and this is a small part of it:

<span class="p-3">3</span>

I try this:

soup = BeautifulSoup(html_text, "lxml")
price = soup.find_all("span", class_="p-3")
print(price)

However it returns None, anyone got a clue?

haughty isle
haughty isle
#

what does your flask code look like?

#

and why are you involving js here? it's a type="file" input element

#

it should just work without js

#

and you see request.files ?

haughty isle
#

why await?

#

wait why async?

haughty isle
#

Well that's not flask

#

What happens when you do that?

plucky wadi
#

Hey , I want to create a countdown timer and the number of minutes should come from a Django model object.Which model field fits for this purpose ?

shy island
#

im trying to use puppeteer to scrap the crypto data from coin market cap but i found that only the first few data can be scrapped. Does anyone know how to scrap more with puppeteer?

#

ok problem fix, the keyword is "lazy loading"

tight ocean
#

Hey guys! Is there any way to plot a normal distribution graph in Flask?

#

Everytime I plot one, a window pops up instead of returning it into the browser

tight ocean
thorn igloo
#

what are you using to plot then

tight ocean
#

It just plots a graph for me, but displays it in an alternative popped up window

#

Right now I am indeed using Matplotlib, but that's why the error occurs

thorn igloo
#

yea. so save the figure as a picture format then serve it with flask

tight ocean
#

Ah, I see

thorn igloo
#

you can't physically plot it on your browser

#

it's a gui thing if that makes sense

tight ocean
#

So everytime I use different variable values, it will just generate new images for me?

thorn igloo
#

yes,

tight ocean
#

Great, I will check if that works

#

Thank you for your time

#

It works!

shrewd meadow
#

jinja

#
        <div class="content-body">
            <!-- row -->
            {% include 'pages/index.html' %}
        </div>
#

i want to replace index.html with variable

#

like i will pass the {"page": "index.html"}

#

while rendering

native tide
#
<?php
    $connection = mysqli_connect("local","username","password","api") or die("MySQL failed to connect ensure creds are correct... " . mysqli_error($connection));
    $id = $_GET['id']; 
    $sql = "SELECT * FROM users WHERE id="; //here I want to parse the value of the GET HTTP Variable **id** ?id=1337 into the statement (I know if I don't escape it then I will end up with an SQL Injection vuln but that's what my end goal is not sure if mysqli_query() function will prevent that but if it is I will find an alternative way of parsing the query. 
    $result = mysqli_query($connection, $sql) or die("Error in Selecting " . mysqli_error($connection));
    $f = array();
    while($row =mysqli_fetch_assoc($result))
    {
        $f[] = $row;
    }
    echo json_encode($f);
    mysqli_close($connection);
?>

Thanks! ๐Ÿ™‚

#

id=the_users_value < goal

haughty isle
#

and also this is the python discord - not php

native tide
native tide
warm igloo
#

real easy to use placeholders and the whole server is python themed so yeah we tackle web here but in context of python

#

you can ask but don't always expect answers since it's likely that this server is more python devs than php devs

#

at end of day, php IS off topic for the server

native tide
#

Of course, I expect that but can't find any PHP Servers.

dense slate
warm igloo
#

there's also the OT channels

native tide
warm igloo
#

but yes, look up doing sql with PDO and also look at how to use placeholders for safe sql

warm igloo
#

everything in this server, except OT, is FIRST python themed, THEN broken down into other python-related topics

native tide
#
    $sql = "SELECT * FROM users WHERE id="; //here I want to parse the value of the GET HTTP Variable **id** ?id=1337 into the statement (I know if I don't escape it then I will end up with an SQL Injection vuln but that's what my end goal is not sure if mysqli_query() function will prevent that but if it is I will find an alternative way of parsing the query. 
warm igloo
#

okay so what do you want? just inject your variable in that sql statement and boom, you have a vuln

native tide
warm igloo
#

literally just put $id in your string or concatenate it on .. either way, it creates a sql injection vuln

#

and you're doing a bad thing on purpose yes?

native tide
#

basically

/api.php?id=1

the sql is configured to use the where query to identify the id column value

if they parse 'OR 1=1 -- -' a true statement it'll drop the everything I need

native tide
warm igloo
#

what what?

#

You're saying you WANT it to be vulnerable yeah?

#

That's the goal?

native tide
#

Bad purpose? Have you ever heard of pentesting or an instructor?

#

yes lol

warm igloo
#

lol, don't get pissy homie

native tide
#

If its for a bad purpose i'd be attacking the application not adding intentional vulnerable code.

warm igloo
#

We're not usually in the business of helping people purposefully write BAD code

native tide
#

I am not, you're getting the wrong concept/

dense slate
#

This guy. ๐Ÿคฆ๐Ÿผโ€โ™‚๏ธ

warm igloo
#

Is this a hidden camera show? LOL

native tide
warm igloo
#

I told you how

#

wtf

native tide
#

Where?

#

You mean by place holders?

#

or the PDO thing

#

I assume place holders

warm igloo
#

no

haughty isle
#

PDO supports parameterized queries

  $dbh = new PDO("mysql:host=$servername;dbname=myDB", $username, $password);
  // set the PDO error mode to exception
  $dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
  $sth = $dbh->prepare("SELECT username FROM users WHERE id=:user_id", array(PDO::ATTR_CURSOR => PDO::CURSOR_FWDONLY));
  $sth->execute(array(':user_id' => $id))->fetchAll();
warm igloo
#

they don't wan ttthat

#

they don't want SAFE code

#

lol

native tide
#

I am testing others how to test for SQL Injection in BBP's or when they're doing a web app pentest.

warm igloo
#

If you want UNSAFE code, I said just literally put $id in your SQL statement

native tide
#

That's why I need it to be unsafe

native tide
warm igloo
#

I'm sorry. You're an instructor?

native tide
#

Pentest**

#

Difference ๐Ÿ™‚

haughty isle
#

difference between what and what?

native tide
#

If you don't know the difference between a web app pentester and a web app developer then I suggest you don't help because you're getting confused here.

#

I am not teaching them to write PHP Code.

warm igloo
#

fuck if I know

native tide
#

That's the difference.

#

You've got the wrong perception here.

warm igloo
#

You're very bad at explaining.

dense slate
#

You have no idea how to ask for help, dude.

native tide
#

Congregating and all winging at me for asking a question?

#

** $sql = "SELECT * FROM users WHERE id="; //here I want to parse the value of the GET HTTP Variable id ?id=1337 into the statement (I know if I don't escape it then I will end up with an SQL Injection vuln but that's what my end goal is not sure if mysqli_query() function will prevent that but if it is I will find an alternative way of parsing the query. **

#

very simply question

#

Just read

warm igloo
#

put the variable in the string wtf

dense slate
#

Then figure it out yourself if it's so simple.

warm igloo
#

yeah, super simple, good luck

native tide
#

Who said it's simple?

#

I said my question is simple

warm igloo
#

I'm sure you're a real successful pentester

native tide
#

Not the solution

#

That's two different things.

native tide
#

๐Ÿ™‚

#

Difference between zero-day hunters and Pentesters.

#

We don't usually have access to the backend ๐Ÿ™‚

#

I still don't think you know the actual definitions lol

#

We test stuff blindly

warm igloo
#

we're in web dev channel, you posted backend php, and asked how to make it unsafe

native tide
#

I mean if you think I am dumb at what I do with pentesting you can add me and we can hop in a private call and discuss some stuff?

warm igloo
#

sooooorrrry I don't know your life history haha

native tide
#

I asked you something completely different my intention is to make it insecure

#

but

#

If you read the code mysqli_query() is parsing the $sql statement variable which will block any SQLI

#

So by parsing the ID Param isn't making it vuln

warm igloo
#

<< >> <_<

dense slate
#

At this point, it doesn't matter what you think you asked or didn't ask, or whatever, no one is going to want to help you with that attitude.

native tide
#

I don't think you get what I am asking

#

It's fine

native tide
warm igloo
#

nah, the whole conversation can be read

dense slate
#

I'm reading the conversation and can perceive who was doing what for myself, but ok.

native tide
native tide
warm igloo
#

Mmmm, blocked cleared that up real quick. Have fun y'all.

dense slate
#

Thanks

native tide
#

I asked a question ina web dev channel and I got get told that this isn't really for PHP

#

It's okay tho, I can figure it out. I am sure it's easy

#

Fyi his solution doesn't work. I tried it earlier it causes a SQLI error when parsed into the DB

#

Goodnight ๐Ÿ™‚

rigid loom
#

!guilds should have some PHP servers

lavish prismBOT
#

Communities

The communities page on our website contains a number of communities we have partnered with as well as a curated list of other communities relating to programming and technology.

rigid loom
#

(Under the "curated list")

native tide
faint goblet
#

r2toretto โ€” Today at 3:37 PM
Hey guys I had a problem with 100 Days of Code Day 61 Flask and WTForms, about the validation, the docs I think they are horrible or they think we know everything about it, got to love the irony about the docs, anyways, I found this videos that can help anyone that had or will do the 100 Days of Code in Python bookmark this video to help you. This is like a rare pokemon that has only been seen by God himself.
https://www.youtube.com/watch?v=GbJPqu0ff9A&ab_channel=Codemy.com

In this video we'll start to use Web Forms for our Flask project with WTF (What the Forms!).

Web forms with WTF are incredibly easy to use and come with all sorts of features that we need like form validation, CSRF token creation, and even reCAPTCHA.

You can always build out web forms by hand, but using a 3rd party system like WTF just mak...

โ–ถ Play video
nocturne agate
#

should look like this

#

but this is what i get

dense slate
#

Does it ever show or just somtimes?

#

Looks like your background color isn't getting rendered.

nocturne agate
dense slate
#

That or maybe a z-index issue?

#

Without code it's hard to know for sure.

nocturne agate
nocturne agate
dense slate
#

Link to the relevant component or part of the code, I'm not going to be able to search the entire repo for it.

jade fossil
#

hi guy's, does anyone know if heroku is working ?

dense slate
nocturne agate
dense slate
#

show the html snippet of where you apply the css style

thorny glacier
#

Didn't dive into the repo, but just took a quick look in the web console and it looks like the .sidebar has right: -40em. If I set it to 0 instead, it shows up

warm igloo
jade fossil
#

๐Ÿ˜‚

warm igloo
#

check their status page?

jade fossil
#

y

warm igloo
#

huh?

jade fossil
#

it says problems in US and EU services

warm igloo
#

well there you go

dense slate
warm igloo
#

when in doubt, find the status page

jade fossil
#

okay

dense slate
#

Is the sidebar separate from the element that the X is attached to?

thorny glacier
nocturne agate
#

figured it out, closed the div before needed..๐Ÿคฆโ€โ™‚๏ธ

#

1.5hours wasted

tight ocean
#

Anyone any idea how this formula would be written in an IDE?

lavish prismBOT
#

Hey @tight ocean!

It looks like you tried to attach file type(s) that we do not allow (). We currently allow the following file types: .gif, .jpg, .jpeg, .mov, .mp4, .mpg, .png, .mp3, .wav, .ogg, .webm, .webp, .flac, .m4a, .csv, .json.

Feel free to ask in #community-meta if you think this is a mistake.

tight ocean
#

I need it in a variable

dense slate
tight ocean
#

Or else I could've already put it in a var

dense slate
#

So like (((e^(z-u)^2) / (2x^2)) / etc...

#

Just make sure your equation follows pemdas and you should be able to write that out.

tight ocean
#

I will try

haughty isle
#

What does file.save(...)? do?

#

Don't you need to await it?

#

What is the repr of file?

barren basalt
#

Hello does anyone know the best pattern/app structure for flask where you have a single app file and blueprints within a APIs folder? I have python-dotenv to load local config but I am having to repeatedly call the load_dotenv("local.env") in each blueprint file for it to work correctly. There has to be a more efficient setup where you load config once and that is accessible across blueprints

haughty isle
#

Yeah like print(f"{file=}")

barren basalt
haughty isle
#

Try using fetch instead of xhr?

tight ocean
#

Are infinite series in Python possible?

#

((reclaim_rate)^(0) * 0.5^1)+((reclaim_rate)^(1) * 0.5^2)+((reclaim_rate)^(2) * 0.5^3)+((reclaim_rate)^(3) * 0.5^4) and so on to infinity

haughty isle
#

Why would the python backend change anything?

ivory niche
#

Hey, so my html looks good on my main screen, but when i move the window to a smaller screen or reduce the size, the size of the content doesnt change

#

how do i make my html responsive?

hushed vortex
#

please help

#

im using flask, html, css and python

native tide
hushed vortex
#

please help
im using flask, html, css and python
on my pc my website looks like this

#

but on a smaller screen it look like this

#

hwo can i fix this?

elfin trench
#

probably css not flask...

#

code?

native tide
#

Have you messed with media stuff

#

People should start using bootstrap really

elfin trench
#

idk, sometimes its fun to make your own css

hushed vortex
#

which code do you need?

elfin trench
#

just more painful

hushed vortex
elfin trench
native tide
#

Mostly time is costly so pain isn't the best

hushed vortex
#

what is bootstrap?

elfin trench
#

what is .htlm ending

elfin trench
#

makes your life easier

hushed vortex
#

oh leeave that

elfin trench
#

you can look it up

hushed vortex
#

ok

#

i dont use .css

native tide
#

....

elfin trench
#

um

#

you might want to get used to taht

elfin trench
#

if not you can import it from a link

hushed vortex
#

mb

#

ok

elfin trench
hushed vortex
#

this is the file i use for my layout on all my webpages

native tide
#

I understand

elfin trench
#

yeah that's got bootstrap

hushed vortex
#

oh sorry i am new

#

but how can i make the page responsive?

native tide
#

Bootstrap!

elfin trench
#

this is a css/html problem, not python

#

but yes, you could more efficiently use bootstrap

native tide
#

Bootstrap responsive website search and you have immediately 10 links

elfin trench
#

although it looks like they are using it

#

anyway

#

this is specifically flask but...

#

i've been trying to upload a file to a directory and continually get 400 bad request errors.

#
@app.route('/upload/', methods = ['POST','GET'])
def upload():
  if request.method == 'POST':
    pack = request.files['package']
    pack.save(os.path.join(uploads_dir, secure_filename(pack.filename)))

    return 'file uploaded successfully'

this is the upload code...
and below is the html form i'm using:

<form action="https://example.com/upload/" method = "post">
  <input type="file" id="package" name="package"><br>
  <input type="submit">
</form>

(example.com) is just to protect the web address, I didn't screw that up

inland oak
wraith topaz
#

so i have this website and a website i am creating and i need to add python code to a button so when the button is clicked it will execute the python code

orchid olive
#

how can i make my pc an https server using python and flask?

inland oak
#

Alternatively... if all u need to invoke python code without any input data, u can just use <a> tag, it will make GET request to any specified url

#

Sure, frontend frameworks are used to change web site without refreshes

elfin trench
#

ignore lol

#

wrong discord

inland oak
#

do u wish your server being accessed only by local users, without public usage?
if yes, it can be achieved with different levels of difficulty, depending on your current OS

#

if u wish it exposed to the world, than u need (public / white / static (synonyms)) IP address for your PC

thorn igloo
hushed vortex
#

@inland oak you there?

wraith topaz
#

or i am just restart and i am use djano

#

can anyone help

inland oak
#

read, learn, apply

wraith topaz
#

i want to make a website that can run open-cv projects made in python on a pc and or phone

inland oak
#

read the guide if necessary, how to ask questions right

inland oak
#

u need to specify prevent default behavior, it is surely possible

cursive pine
#

folks,
The goddamn iphone changes the letter A and H to black. And only these 2 letters. Anyone know what the hell is the problem? Works fine on android.

inland oak
#

in this video there is mention how to do that for vanilla JS, i copied the right second for that
https://youtu.be/cuHDQhDhvPE?t=207

I built a simple app with 10 different JavaScript frameworks... Learn the pros and cons of each JS framework before building your next app https://github.com/fireship-io/10-javascript-frameworks

#javascript #webdev #top10

๐Ÿ”— Resources

Full Courses https://fireship.io/courses/
Performance Benchmarks https://github.com/krausest/js-framework-benc...

โ–ถ Play video
#
form.onsubmit = (event) => {
            event.preventDefault();
            addTodo(input.value);
        }
#

ev.preventDefault(); as codeline to your code

#

for input field todo

#

for its value (text)

drowsy rune
#

Has anyone come across any fastAPI boilerplate, like say authentication/db minimal front end?

livid depot
#

Is python used for web dev?

native tide
#

django and flask yes

inland oak
#

and fastapi ;b

karmic sun
#

Would python be slower as a backend than if you used java

plush grove
#

please help me solve this question

haughty isle
#

You await it

#

Just like you'd handle a Coroutine in Python

karmic sun
# native tide yes

but is speed in a backend something you should take in to consideration when you are choosing backend

haughty isle
#

So make it an async function

#

Show your code?

#

The server returned 404

#

Don't template your <script> code

#

Put your js in a .js file and load it with static files

#

Don't template JS use a static file

<script
  src="{{ url_for(...) }}"
  type="module"
  data-guild-id="{{ guild_id}}"
  data-upload-url="{{ url_for('upload') }}">
</script>
#

Then you get the data with:

const { guildId, uploadUrl } = document.currentScript.dataset;
haughty isle
#

The .js file at the top

#

Also add export {}; to the bottom to show it's a module

#

You don't need templates at all

#

Just server_id: guildId

#

Yes the last line of the js file

#

Show your code and full traceback

#

Ah woops it doesn't work with modules

#
<script
    src="{{ url_for(.../static/main.js) }}"
    type="module"
    id="my-metadata"
    data-guild-id="{{ guild_id }}"
    data-upload-url="{{ url_for('upload') }}">
</script>โ€Š
const { guildId, uploadUrl } = document.getElementById("my-metadata").dataset
#

@charred sphinx I forgot you have to use an id instead

#

Ah don't use onclick

#

Use addEventListener

#

Give the form an id then select the button

#

$( "#form-id-here" ).on( "click", ".save" submit_form);

#

Ok select the button in a different way

#

You can use $(".save").click(submit_form);

#

It's addEventListener not onclick

#

Just after you define the submit_form function in your .js file

#

That's the server returning a 400 look at your server's logs

#

And look at the http response in the network tab

#

See where it says response

#

On the top right

#

Show the full output

#

You cut the important part

#

You probably want to run your server in debug mode to see the traceback

#

But it's because you're accessing a key on your form that you didn't send

#

Ok well stick a try: except Exception as e: breakpoint(); raise around your upload handler

#

Yeah

#

The whole thing

#

You missed a line at the top

#

Yeah try that

lavish prismBOT
#

Hey @charred sphinx!

Uh-oh! It looks like your message got zapped by our spam filter. We currently don't allow .txt attachments, so here are some tips to help you travel safely:

โ€ข If you attempted to send a message longer than 2000 characters, try shortening your message to fit within the character limit or use a pasting service (see below)

โ€ข If you tried to show someone your code, you can use codeblocks
(run !code-blocks in #bot-commands for more information) or use a pasting service like:

https://paste.pythondiscord.com

haughty isle
#

@charred sphinx what happens?

#

Ah show the exception !e

lavish prismBOT
#
Command Help

!eval [code]
Can also use: e

*Run Python code and get the results.

This command supports multiple lines of code, including code wrapped inside a formatted code block. Code can be re-evaluated by editing the original message within 10 seconds and clicking the reaction that subsequently appears.

We've done our best to make this sandboxed, but do let us know if you manage to find an issue with it!*

haughty isle
#

Show it so I can see it

#

With my eyes

#

Type !e to run the expression e which prints the value in e

#

It's like a repl

#

But you put ! first to let it know it's not a debugger command

#

Into the debugger I assume it's running in your terminal

#

uhh

#

try logging it instead? @charred sphinx

import logging
logging = logging.getLogger(__name__)

...
    except Exception as e:
        logger.exception("the bad")
tired kraken
#

Hello there, anyone having few moments of time to help me a bit?

haughty isle
#

@charred sphinx do you get any output? Remember to raise also

#

Sure no need for a semicolon you can use a newline

#

Yeah so there's no key called "file" in your .files object

#

You need to send a form with a file in the file field of the post data

#

Yeah

#

You're sending it as json

#

Get rid of the content-type header

#

Yeah I think so

#

Don't use .then, use await

#

Yes

#

Yes

#

Whenever you see v.then(func) you can use func(await v)

cyan drift
#

anyone could help me with a dumb flask error if possible? I swear it won't take too long

cyan drift
#

Fair enough

#

let me explain

cyan drift
#

https://paste.pythondiscord.com/kelerotitu.py
I have a thread and I want to set global variable which I named distanceVar,temperatureVar, but when I try to use them in my render it gives me a nameError, I have been stuck there for 2h now

haughty isle
#

?

#

So you see v.then(func) in your code? The pattern I'm asking you to look for could have any expression v on the left and any function func on the right

#

e => e.json() is a function

#

And fetch(...) is an expression

#

You have fetch(...).then(e => e.json())

#

So can you see how it fits the v.then(func) pattern?

humble heart
#

Hello, can someone tell me how do I put my website public?

haughty isle
cyan drift
native tide
cyan drift
#

The error really seems to be in my render_template

humble heart
native tide
#

ah

#

well what operating system you hosting your server on

humble heart
#

Windows 11

haughty isle
# cyan drift

Yeah so you didn't define those values globally. But also you need to watch out because this won't work with gunicorn or any normal way of deploying your wsgi app

native tide
#

ah

cyan drift
haughty isle
native tide
#

also not related but windows 11 sucks

haughty isle
humble heart
#

Ok thanks

cyan drift
haughty isle
#

Follow that guide and show your new code

cyan drift
#

oh so make a main method kinda

#

ok ill try to follow that

haughty isle
#

It won't fix your problem but might make it clearer how to fix it

cyan drift
#

but now I can't access dht and capteur in my platine() method anymore

#

what can I do

#

I think I did it good hopefully

#

I return the var in the main so I can grab them in my method

#

does that make sense?

#

idk what I am doing and I need to get this done lmao

haughty isle
#

?

haughty isle
cyan drift
#

I have been working for 10h straight and idk what I am doing anymore honestly. Our teacher gave us a very limited lesson on flask and never teached us thread or anything and I just can't do it. I need to sleep lol

haughty isle
#

You can send anything you want in a FormData object

#

You can append new fields

#

Did it work?

#

Did you try that?

#

Why did you do that?

#

It was fine when you did new FormData(form);

#

Yes, you said it needed a key and a value

#

Did you try that?

haughty isle
plush grove
#

anyone here free to help me please?

#

regarding python

haughty isle
#

which server id?

#

why did you remove the form from the new FormData(form); ?

#

right but that's just an example of how to make an empty FormData()

#

you want a FormData() with the data from your form and some additional data

#

ok does it work?

#

where's "serverID" in your JS code?

#

ok but why are you looking in request.files for serverID?

#

that's for files

#

I'm not totally sure why request.form doesn't contain files but there we go

#

oh wait you're using quart

haughty isle
#

what?

#

looks like it's working to me?

#

show your code

#

don't use a bare except:

#

just catch the exceptions you expect to see

#

just catch the exceptions you expect

#

also don't call chdir

#

just save to the path you want to save to

#

right you don't need to chdir fort that

#

what makes you think that?

#

just:

UPLOAD_PATH = pathlib.Path("/path/to/static/upload")

async def upload():
    ...
    path = UPLOAD_PATH / werkzeug.secure_filename(guild_id) / "thumbnail.png"
    await quart.run_sync(path.parent.mkdir)(parents=True, exist_ok=True)
    await file.save(path)
dense slate
#

Are you able to update without refreshing without having some JS on the front-end?

#

Or maybe I'm just assuming and you do actually have JS to handle the front-end.

haughty isle
#

oh I see

#

I updated the code @charred sphinx

#

or maybe

#
UPLOAD_PATH = pathlib.Path("/path/to/static/upload")

async def upload():
    ...
    guild_dir = UPLOAD_PATH / werkzeug.secure_filename(guild_id) 
    await quart.run_sync(guild_dir.mkdir)(parents=True, exist_ok=True)
    await file.save(guild_dir / "thumbnail.png")
inland oak
#

Catching just Exception is almost as bad as just Except. It is number one worst thing to do in python, because it makes debugging a hell. It makes ignored even syntax errors

cyan drift
#

But he showed us the bare minimum for flask so its all learning

vestal tartan
#
import algo.config as config
import asyncio
import websockets as ws

ws_client = WebsocketClient(api_key=config.api_key, secret_key=config.secret_key)
async def main():
            asyncio.create_task(
                ws_client.connect()
                )

            await ws_client.subscribe(
                events=["!ticker@arr"],
            )      

loop = asyncio.get_event_loop()
loop.create_task(main())
loop.run_forever()
loop.close()```
#

I can get it to output in a console but I cant get it store in a variable

#

/list

#

its using this module

tight ocean
#

Can anyone help me? I get TypeError: Invalid status argument error

balmy knoll
#

guys i'm making a login page but I need to verify if the fields are empty and if the fields are empty the border of the input should turn red. But it's not working... Here's the code

thorn igloo
tight ocean
# thorn igloo no one knows what your code looks like or what you are trying to do thats giving...

from flask import Flask, render_template, request
from flask.helpers import url_for
import matplotlib
import matplotlib.pyplot as plt
matplotlib.use('Agg')
import scipy.stats as stats
import numpy as np
import math
import pandas as pd
import plotly.express as px


app = Flask(__name__)

# Home page
@app.route("/")
def home():
    return render_template('index.html')

@app.route("/", methods=['POST'])
def my_form_post():
    mu = 0
    n = 5
    burn_chance = request.form['burn_chance']
    burn_chance = int(burn_chance)
    burn_chance = (burn_chance / 100)
    reclaim_rate = (1 - burn_chance)
    for n in range(n):
        p = ((reclaim_rate)**(n-1) * 0.5**n)
        u = p * n
        o = math.sqrt(u * (1-p) * p)
        n += 1
    x = np.linspace(mu - 3*o, mu + 3*o, 100)
    plt.plot(x, stats.norm.pdf(x, mu, o))
    plt.savefig('static/images/plot.png')
    return render_template('index.html', url='static/images/plot.png'), reclaim_rate
    
if __name__ == "__main__":
    app.run(debug = True)```
thorn igloo
tight ocean
thorn igloo
#

but you know what you are doing thats causing this error

tight ocean
#

It has to do with request.form['burn_chance']

#

when I leave out burn_chance = int(burn_chance), it says uncompatible operand type str int

thorn igloo
#

what is reclaim_rate?

#

i thinks this line

#

return render_template('index.html', url='static/images/plot.png'), reclaim_rate

#

might be where your error is

#

why are you putting reclaim_rate there?

tight ocean
#

It needs to plot the value of reclaim_rate

#

To return that value

thorn igloo
#

when you do something like return x , y for a flask module, y should a valid http status code

#

whatever you're putting there is not valid

tight ocean
#

The error occurs when I change upper lines though

thorn igloo
#

This is a list of Hypertext Transfer Protocol (HTTP) response status codes. Status codes are issued by a server in response to a client's request made to the server. It includes codes from IETF Request for Comments (RFCs), other specifications, and some additional codes used in some common applications of the HTTP. The first digit of the status ...

tight ocean
#
    burn_chance = int(burn_chance)
    burn_chance = (burn_chance / 100)```
#

These

thorn igloo
#

im telling you what that is reffering to

tight ocean
#

How could I then return the page and input values?

thorn igloo
#

where is the input value supposed to go?

tight ocean
#

There are gonna be added 2 more, so that would be problematic

thorn igloo
tight ocean
#
    plt.plot(x, stats.norm.pdf(x, mu, o))```
#

It will eventually plot the values

thorn igloo
#

what?

#

you want a function to return a value, and use that value within that function, am i understanding you correctly?

tight ocean
#

Yeah

#

To then plot it and convert it to an image

thorn igloo
#

does that make sense to you?

tight ocean
#

Wait

#

I'm dumb

#

LMAO

#

I was using 2 functions before, completely forgot about it

thorn igloo
#

hmm

tight ocean
#

It seems to be working way better

#

Error is gone

thorn igloo
#

cool i guess

tight ocean
#

ty

balmy knoll
#

guys how can I remove an html button using flask

#

?

thorn igloo
balmy knoll
#

Like when the user inserts the wrong email, the login button should disappear

#

butttt

#

there's one more important thing

thorn igloo
#

conditional rendering could solve this for you

#

and that is?

balmy knoll
thorn igloo
balmy knoll
#

ok

thorn igloo
# balmy knoll

k, so you have emailEmptyField but you're not passing this variable to your form

#

or html page rather

#

so login_template is where you want to use this variable right?

balmy knoll
#

yes... but I think i'm using it...? With the conditional rendering

#

right?

thorn igloo
#

you need to do this

#

return render_template(login_template, emailEmptyField = emailEmptyField)

#

that should work properly

balmy knoll
#

yessir! It works! Thank you! I'm currently a newbie in web dev xD

rancid blaze
#

anyone here knows how to scrape dynamic websites using selenium ?

thorny rover
normal hatch
#

Hey guys can anyone help me cause my image is not appearing in my html file in chrome and Microsoft edge but it appears when i open live server in vs code in microsoft edge ,it is confusing and here is my codes and webpages screenshot and then share the code to me thank you ๐Ÿ™‚

dense slate
#

Does the theme follow what you have set in Chrome or is it a page-specific setting?

thorny rover
#

it follows the system wide theme.

dense slate
#

I think it would be awesome if as you go down, you're descending through layers of the Earth, or better yet, some kind of dungeon or adventure-style level for each section

thorny rover
#

that would be nice!

#

I'm going to do that, make it look like there are things buried more and more as you scroll

dense slate
#

Would love to see updates. Do you do the art?

thorny rover
# dense slate Would love to see updates. Do you do the art?

Not here. at least not the main parallax art. Those are through freepik premium. Though each layer is a different base eps file that I then edit in ps and illustrator to match my design, remove backgrounds, change colors and things like that. But then stuff like my logo and my photo I did.

hushed vortex
#

please help \

#

my style sheet is not working

dense slate
#

css usually goes in your static folder

warped aurora
hushed vortex
warped aurora
#

Flask uses the static folder as the default root for files

hushed vortex
#

ah

#

so i should make a static folder and put my css in it

warped aurora
hushed vortex
#

ty

dense slate
#
<head>
    <title>Flask Shop</title>
    <link rel="stylesheet" href="/static/style.css">
  </head>
#

Basically something along those lines.

warped aurora
#

^

dense slate
#

And you might need to collectstatic - I don't know if flask requires that like Django does.

warped aurora
#
@app.route("/", methods=("GET", "POST"), strict_slashes=False)
def index():
    if current_user.is_authenticated:
        return render_template("index.html", title="Home")
    else:
        return redirect(url_for('login'))


@app.route("/login/", methods=("GET", "POST"), strict_slashes=False)
def login():
    form = login_form()

    if form.validate_on_submit():
        try:
            user = User.query.filter_by(email=form.email.data).first()
            if check_password_hash(user.pwd, form.pwd.data):
                login_user(user)
                return redirect(url_for('index'))
            else:
                flash("Invalid Username or password!", "danger")
        except Exception as e:
            flash(e, "danger")

    return render_template("login.html",
                           form=form,
                           text="Login",
                           title="Login",
                           btn_action="Login"
                           )

trying to figure out why when I go the login page via redirect the css folder path lookup changes to
"GET /login/static/custom.css HTTP/1.1" 404 -
instead of
"GET /static/css/custom.css HTTP/1.1" 200 -

dense slate
warped aurora
#

uhh don't think I have one of those lol

dense slate
#

ah

#

Flask, then. Not sure.

#

my guess would be something where you have a / where it shouldn't be

#

so it doesn't create a relative path

#

so maybe login/ instead of /login/?

bronze briar
#

hi, nice to meet with y'll. i got stuck with a flask problem and wondering if anyone can help.

warped aurora
dense slate
#

ah great

warped aurora
#

Cept i don't fully get it lol

dense slate
#

Having the extra slash changes whether the route is relative or absolute I believe

normal hatch
#

Hey guys can anyone help me cause my image is not appearing in my html file in chrome and Microsoft edge but it appears when i open live server in vs code in microsoft edge ,it is confusing and here is my codes and webpages screenshot and then share the code to me thank you

warped aurora
hushed vortex
#

please help

#

my button wont move any higher thanthis

cold portal
#

Maybe itโ€™s stuck in a div pushing it down

#

Has anyone encountered an issue where django suddenly generates a number of sleeping database threads and the web app stops responding? It can go on for days or weeks with no issue or each day could have problems. Restarting Apache clears out the db connections, but they usually just stack up immediately when Apache starts. Seems to line up with the potential peak time, but resources donโ€™t seem to be an issue. Any ideas on what to look for?

hushed vortex
cold portal
# hushed vortex how can i fix that?

Iโ€™d have to look at the html, but essentially what Iโ€™m suggesting is to review your html to see where the button element is located and whatโ€™s around it. Maybe itโ€™s contained within a tag that keeps it locked down

#

In my experience, itโ€™s always another divโ€ฆ. Damn divsโ€ฆ

hushed vortex
cold portal
#

So that divโ€ฆ is it within another div?

dense slate
#

Didn't you just have this issue? You usually need an ajax or other JS call to the backend so that it re-renders without refreshing.

thorny rover
thorny rover
#

layers tab, its under settings, more tools, layers

thorny rover
dense slate
# thorny rover

On your site did you just layer divs over one another with separate images that have transparent BGs? Besides the parallax stuff.

thorny rover
#

oh I also kind of did that for the work section, those are divs with text, then on hover the div and text go transparent

#

but the tech section is a grid with perspective and RotateY, on hover it uses scale

hushed vortex
dense slate
#

For the trees over the background for example

#

Gotcha

hushed vortex
thorny rover
thorny rover
# hushed vortex

you can right click those document tags and expand them to get more info

hushed vortex
#

wh is this so big?

cold portal
hushed vortex
#

i fixed it

#

whats the difference between margin and top, left?

cold portal
#

Not sure. Not strong with styling. Itโ€™s always a PITA for me lol

hushed vortex
#

lol

desert cradle
#

How do i use multiprocessing in Django?

dusk portal
#

the thing i'm making a quiz app using django , so i have 20 quizes (img format) i wanna render all the quizes 1 by 1
(via POST req)

#

so the issue is when i hit next it submits n saves the data to db + renders the result page
n when i remove the next button (which was in form tag) so it doesn't show any error it opens the next quiz question but it doesn't send post request so how can i then make result
my one friend told me that write a condition it should save when all 20 questions r done

inland oak
dusk portal
inland oak
#

top, left is for relative/absolute/fixed positional movements

#

for example we can freely move with top, left, bottom, right outside of the object borders

#

which was perfect to shift appeared menu outside of the parent object

#

like this dropdown meny

#

plus with top, left, bottom, right, we can position child object at ANY corner of the object

haughty isle
#

don't use bare except, remember to use pathlib and not os.path and always do blocking path calls with quart.run_sync

#

also use functions for all your duplicate code

dusk portal
#

@haughty isle can i get help sir

haughty isle
#

and fix the driectory traversal vulnerability

#

what do you expect secure_filename(f"thumbnail.png") to do?

dusk portal
#

@inland oak hey , wassup bro

haughty isle
#

show your code with the suggestions I made applied?

#

this stuff

#

I fixed it for you when I gave you code for if yesterday

haughty isle
#

You need to call

guild_dir = UPLOAD_PATH / secure_filename(guild_id)
#

Then you can use guild_dir / "thumbnail.png" etc

verbal helm
#

hey coders, I just needed help!
Currently, I am learning to build websites with Django. And I have finished one, now I wanna deploy it but I will be needed an Amazon AWS account. because I need to use RDS to push my static files. But I am under 18 now, I do not have any credit cards, also I have already tried with my parent's credit cards but that didn't work as their bank didn't support any international transfer.
So can anyone help to create or get an amazon AWS account? please? I would be really grateful

N.B: "I know that I can also deploy the website on pythonanywhere for free, but this is some kind of a professional website"

haughty isle
#

Show your full code and Traceback

#

Where is your pathlib import?

#

Show the code

#

The whole file, because I can't see pathlib anywhere here

#

I still don't see pathlib anywhere...

#

You're supposed to use pathlib.Path

#

Then you don't need os.path anymore

#

Nope

#

Don't use f" for paths

#

Use guild_dir = UPLOAD_FOLDER / secure_filename(guild_id)

#

Also you don't need to check it exists because you just wrote the file

digital hinge
#

@charred sphinx you may need Ajax

digital hinge
#

So things load on a static page for your emojiโ€™s

valid pecan
#

Hello,
Somebody knows the Django Rest Framework and Django channel to ask questions? Thanks ๐Ÿ™๐Ÿฟ

haughty isle
scenic galleon
#

hi i get FileNotFoundError: [Errno 2] No such file or directory: '/output.png' when i try to send_file through flask but i did os.listdir('.') and it lists the file tho

#

does the files should be in a folder like templates?

golden bone
golden bone
scenic galleon
verbal helm
golden bone
hushed vortex
#

how ca n i align a button to the bottom left in a button?

#

im only able to move it left

random sand
#

Dang that's good

strong valley
hushed vortex
#

that will make it in the center

strong valley
#

try line-height

inland oak
# hushed vortex

copy code as text. screenshots are bad. I am lazy to rewrite your code from screenshot in order to give working example

#

anyway, I am usually using flexboxes as universal gun

#
display: flex;
justify-content: flex-start;
align-items: flex-end;

this will move things to bottom-left

hushed vortex
#

i just need the text to move to bottom-left

inland oak
#

as alternative solution ๐Ÿค”

#

u can write code like

.button {
  position: relative;
}

.text_in_button {
  position: absolute;
  bottom: 10px;
  left: 10px
}
#

it will move stuff to bottom left too, less elegant solution though

#

as it is not promising to hold content inside of the object in comparison to flexbox solution

#

wait a second, there is vertical-align property

#

lets try to use this one

inland oak
#

xD, this will require using old school stuff

#

super bloated code in result

#
      .button {
      }

      table, td {
        height: 100%;
        width: 100%;
        vertical-align: bottom;
        color:#fff;
      }

    <div class="button">
      <table>
        <tr><td>Some random text</td></tr>
      </table> 
      
    </div>
#

we can align with usage of tables

#

because vertical-align property can be applied at least to its cells

#

much dumber solution than using flexboxes or absolute-relative positioning๐Ÿค” perhaps vertical alignment can be applied to smth else

#

oh well, we have fourth method left

inland oak
#

comparing all methods, obviously flexboxes win

native tide
#

Hey, I'm trying to add a footer to my page, but it keeps sticking to the bottom of the screen rather than sticking to the bottom of the page itself

#

I use bootstrap v5.1

#
<footer class="fixed-bottom text-center text-white" style="background-color: rgba(39, 41, 46, 0.95);">   
    <!-- Copyright -->
    <div class="text-center p-3">
        ยฉ 2021 Copyright:
        <a class="text-light" href="https://mygames.idevision.net/">MyGames.iDevision.net</a>
    </div>
    <!-- Copyright -->
</footer>```
thorn igloo
#

use flexbox

#

you can push it down with it

#

your class is probably applying position: fixed

#

flex and flex grow property i believe

#

so basically, whatever is in the middle needs to grow to fill the remaining space

native tide
thorn igloo
#

wait, nvm

#

let me send a codepen

vestal tulip
#

guys where should i put this code to generate a Json view in my terminal ? (in a django project) import json datas = [{'title':'a cool title','artist':'john doe','year':2020},{'title':'a second music'}] print(json.dumps(datas, indent=4))

native tide
thorn igloo
#

something like that

#

you can probably use body as your container here

#

but whatever comes before your footer needs to be contained in a parent div or something for this to work

#

or you can just add the flex grow property to the element before the footer

#

whatever works for you

native tide
#

Thanks! That works wonderful. I've spread it across the body {} and main {} and now its finally at the bottom of the page HappyDance

thorn igloo
#

nice

native tide
#

Do you also happen to know how fastapi works?

thorn igloo
#

haven't really used that,

#

just used flask a lot

native tide
#

Because that's what I use for my page and I somehow cant get it to use css files. It will only use css if I put it inside the html file pain

native tide
#

I have to put all css classes in the <style> in the html file

#

because it for some reason wont get it from a .css file

thorn igloo
#

oh, so it's not serving the css file?

native tide
#

yea

#
app.mount(
    "/static",
    StaticFiles(directory="/home/dutchy/gamesite/static"),
    name="static",
)```
#
<link rel="stylesheet" href="{{ url_for('static', path='/css/main.css') }}" type="text/css">```
thorn igloo
#

yea im mainly a flask guy, not sure about fastapi

hushed vortex
#

but i tried something and it might work

#
<button type="submit"; class="living_room_button"><h1 style="position: absolute; top: -10; left: 60; text-decoration: none; font-size: 16px; color:white;">Living Room</h1></button>```
thorn igloo
#

i mean is the structure like this

native tide
thorn igloo
#

why not use a relative path?

#

seems like you specified the entire folder from your home folder

native tide
#

yea, idk. I've tried a couple things but none seemed to work

thorn igloo
#

just static doesnt work?

native tide
#

doesnt seem like it

thorn igloo
#

yeah idk

hushed vortex
#

please help
<button type="submit"; class="living_room_button"><p style="position: absolute; top: 11; left: 25; text-decoration: none; font-size: 16px; color:white;">Living Room</p></button>

#

it just stays there

#

no matter how much i change the top and the left

thorn igloo
#

you need to specify a unit for your top and left

hushed vortex
#

oh right

#

sorry

hushed vortex
#

anyone know why when i movee my img

#

thermostat_up_button, thermostat_down_button and thermo_tempalso move?

thorn igloo
#

why you using positioning for this layout? why not use flexbox or grid?

south meadow
#

Somebody that might be able to help me with selenium?

hushed vortex
thorn igloo
#

a hypothetical situation

hushed vortex
#

mhmm

thorn igloo
#

say you wanted to add a new component

#

you realize that you're gonna have to reposition everything right?

hushed vortex
#

yessssssss

thorn igloo
#

so save yourself the work and learn flexbox or grid. not that hard to grasp

hushed vortex
#

ok

#

also why cant i see my image?

#

@thorn igloo

thorny rover
#

that means the path you gave for the image is likely wrong

hushed vortex
#

@thorny rover

thorn igloo
#

if you're using flask

#

if not look up how to do it in your framework

hushed vortex
thorn igloo
hushed vortex
#

@thorn igloo my pic is png but it does this

thorny rover
indigo kettle
#

now export to jpg and then screenshot it on your phone

steady cargo
#

just made my first website!

#

and uploaded it to the internet

#

never felt a rush like this before lol

#

I used a free web hosting service and those are shite and messed things up but free is free

hushed vortex
#

please help i want to reference a python function in my html file

#

html file:

lapis glade
#
<title>Hello from Flask</title>
{% if name %}
  <h1>Hello {{ name }}!</h1>
{% else %}
  <h1>Hello, World!</h1>
{% endif %}```
from https://flask.palletsprojects.com/en/2.0.x/quickstart/#rendering-templates
haughty isle
lapis glade
hushed vortex
lapis glade
hushed vortex
lapis glade
#

ok

#

you need to remove the {{ and }}

hushed vortex
lapis glade
#

yea

#

should work

#

try it

hushed vortex
#

ok

#

now my website wont load

lapis glade
#

any errors in the console?

hushed vortex
#

nope

lapis glade
#

huh, super weird