#web-development

2 messages Β· Page 13 of 1

oblique steeple
#

i'm tutoring a student who's currently using pycharm, but it's a bit heavy for his computer.

#

i mean, i'm sure it works, but i'm wondering if spyder's focus on scientific development has downsides for web development

proper hinge
#

Isn't spyder geared for scientific use

#

Yeah

#

I've never used it personally

#

I'd suggest something like VS Code or Atom as a light weight editor

oblique steeple
#

that's probably a better idea

proper hinge
oblique steeple
#

thanks!

upper mango
#
def admin(request):
    return render(request, "./templates/adminpage.html")

urlpatterns = [
    path(r'admin/', views.admin),
    path(r'about/', views.about),
    path(r'home/', views.home)
]

this does not work it says no template found

#

but there is

#

nvm i fixed it

winter pagoda
#

Do Selenium questions go here?

native tide
#

I find Atom pretty heavy

#

Notepad++ is very lightweight and will do alright with the NppExec plugin to add a terminal

meager anchor
#

calling atom or vscode lightweight is a bit of a far stretch πŸ€”

#

anyways, @winter pagoda, yes

proper hinge
#

its all relative

#

idk what its like to have a potato pc

#

even my 2011 baseline macbook managed to run pycharm

winter pagoda
#

@meager anchor thanks, I got some help in #help-croissant which pointed out that element.screenshot() works on Firefox but not Chrome because ?

#

Do people here that use Selenium have a preference between Chrome and Firefox?

#

I've done all my stuff in Chrome until now, my one attempt at running one of my scripts in Firefox seemed to have it not waiting properly and trying to find elements while pages were still loading

#

But I certainly didn't give it much of a fair try

rigid turtle
native tide
#

resources for web dev?

buoyant ledge
#

What is required to do to a web server to see updated content like your backend when you push a new update? Is it a restart of nginx or something else?

buoyant ledge
#

I guess by backend I mean if I clone a GitHub repository in place so the .py files are different than they were before. Do you have to restart nginx? Does disabling caching work?

little nexus
#

if you have got the new .py files, restart gunicorn/whatever server you use

#

nginx is the just the reverse proxy so that makes no difference

#

caching could affect it; depends exactly what is being cached

buoyant ledge
#

Kk

rigid turtle
pale relic
#

need web developer urgent, not very deep pockets, still please help

brave mantle
#

We don't have a recruiting system here

#

If you're a developer yourself, feel free to ask questions about your issue

wicked path
#

How does everyone feel about webscraping?

crystal obsidian
#

@wicked path I've read that question 3 times and it makes me wonder... is there a correct answer to it? What is the actual response you'd expect to receive? xD

tame viper
#

webscraping is fine as long as the website in question doesn't prohibit it

wicked path
#

I just want to know peoples mindset is regarding scraping that's all

crystal obsidian
#

I think it's cool

#

especially using python where it's made almost as simple as it could be

unreal dagger
#

Anyone ever use wagtail or django based CMS?

meager anchor
#

for sure. don't ask to ask if you have a question

stark yarrow
#

Hey what are the ways to send data between routes?
I am building a system to list products on a marketplace.
I have a route with a form for writing the product info. From that, it sends through a function to build a JSON file with that info, then I send it through their server to validate this json.
If it's valid I want to send to another route to confirm the post. My problem is that the JSON file is relatively big, and I create 4 versions of it, with different prices.
I tried to send it via session cookie(eg: session['json']). But the data is bigger than what is allowed, and if the user opens several tabs with different products, it'll overwrite the variable.
I then tried to save it to the database, but it'll also be overwritten if the user opens several tabs.
The only one working properly is sending the data via URL, but the URL is too long now, and makes it harder to debug.
Anyways, is there another (better) way to do it?

#

Oh, and I'm using flask

queen needle
#

Cache?

#

You use the session cookie as a key component for a value stored in a caching server, memcached or redis or w/e

#

If you're not deploying to the masses, you can also just keep it in memory

#

Try Flask_Session

#

@stark yarrow ping since it was an hour ago

#

By default it will keep the server side session in memory

#

Just make sure you're not storing hundreds of MB of json

stark yarrow
#

@queen needle Thank you. I will check it out!

keen ore
#

anyone here who can help with authlib?

meager anchor
#

!t ask

lavish prismBOT
#
ask

Asking good questions will yield a much higher chance of a quick response:

β€’ Don't ask to ask your question, just go ahead and tell us your problem.
β€’ Try to solve the problem on your own first, we're not going to write code for you.
β€’ Show us the code you've tried and any errors or unexpected results it's giving
β€’ Keep your patience while we're helping you.

You can find a much more detailed explanation on our website.

keen ore
#

how can i make it work properly, im following the documentation and keep getting errors about missing tokesn etc

#

authlib.common.errors.AuthlibBaseError: invalid_request: A required parameter "client_secret" is missing

#

when i do


oauth.register('linkedin',
               client_id='xxxxx',
               client_secret='xxx',
               access_token_url='https://www.linkedin.com/oauth/v2/accessToken',
               authorize_url='https://www.linkedin.com/oauth/v2/authorization',
               api_base_url='https://api.linkedin.com/v1/',
               client_kwargs={'scope': 'r_basicprofile r_emailaddress'},
               )

@app.route('/oauth/linkedin')
def oauth_login():
    client = oauth.create_client('linkedin')
    redirect_uri = url_for('oauth_authorize', _external=True)
    logs.debug("Redirecting user to linkedin authorize url")
    logs.debug(client.authorize_redirect(redirect_uri))
    return client.authorize_redirect(redirect_uri)


@app.route('/authorize/linkedin')
def oauth_authorize():
    client = oauth.create_client('linkedin')
    logs.debug("Created client")
    logs.debug(client.client_secret)
    token = client.authorize_access_token()
meager anchor
#

which line does that error occur on?

keen ore
#

last line

#

when i run dump on the client.client_secret it does print the correct token

keen ore
#

i can pass client_secret to it by doing client.authorize_access_token(client_secret=client.client_secret) but that is not documented in anwhere properly,
but now, when i do

resp = client.get('people/~?format=json', token=token)
#

i get KeyError: 'token_type'

#

@meager anchor

meager anchor
strong sonnet
#

There's absolutely no way of doing the equivalent of await while in a callback that's not async is there?

async def pointless1():
    print("pointless1")
    await asyncio.sleep(2)
    return 1
    print("pointless1.1")


def pointless2() -> Task:
    print("pointless2")
    loop: AbstractEventLoop = asyncio.get_event_loop()
    task: Task = loop.create_task(pointless1())
    # There is no way here to wait until the task is complete and continue
    # Exception:
    #loop.run_until_complete(task)
    # Invalid state error:
    #task.result()
    return task

async def pointless3():
    print("pointless3")
    task = pointless2()
    # even here it can't be done.
    print("pointless3.1")

loop: AbstractEventLoop = asyncio.get_event_loop()
loop.run_until_complete(loop.create_task(pointless3()))
neat nest
#

why can't it be done in pointless3, @strong sonnet?

keen ore
#

wtf, linkedin only allows selected partners that use their job listings to access the user skills via the api

strong sonnet
#

@worn sapphire it's just an example. pointless3 might call a constructor which is pointless2. You can't make constructors async, so you're basically stuck

#

You really want the class to be fully initialized by the time init returns, but if pointless2 is and init then you're left with a partially initialised class.

#

Yes you can create a callback, but it gets messy.

neat nest
#

why make pointless2 an __init__? it can be a factory function that returns an awaitable future like it essentially is right now

strong sonnet
#

It's not always possible or practical to do that. Yes I guess you can redefine your entire code-base to make everything be async, but it doesn't always work out like that

#

Like... init functions should be the way to initialise a class. That's their entire purpose. You could maybe have an ainit function instead I guess, but having a factory method is untidy

keen ore
#

hmm im having trouble with oauth2 again

#

im using the token i recieved after authneticating with authorization token but i keep getting The token used in this request has been revoked by the user

#

well i solved it

#

linked in cannot understand that some apps can use the token almsot immiteadly

#

by adding a small time delay of 5 secs it works perfectly

neat nest
#

@strong sonnet
(a) it's always possible to wrap an object's creation in an async factory and I have a hard time believing it's frequently impractical
(b) who said anything about making everything async? this is only to address the case of the rare class that needs to be asynchronously initialized
(c) factory patterns are extremely common and in no way, shape, or form inherently untidy unless you've implemented them poorly

native tide
#

Hey guys, I got asked a question to review on my in-person interview: "What is your viewpoint on development flow?" What is development flow exactly? Like... agile development or scrum environments?

deep cave
#

but yeah, probably stuff like LEAN or agile

rugged wolf
#

can someone help me with django? I have the form like

#
class UploadForm(forms.ModelForm):

    class Meta:
        model = Video
        fields = ('title', 'video')
#

and view like

    if request.method == 'POST':
        form = UploadForm(request.POST)

        print(request.POST.get('title'))

        if form.is_valid():
            return HttpResponse('test')
    else:
        form = UploadForm()

    return render(request, 'upload.html', {'form': form})
#

and the problem is form.is_valid() is never true.

#

it always dumping my form with error under title - This field is required

elfin mirage
#

Does anyone have experience with setting up multiple python sites in IIS using wfastcgi? I'm not sure how I properly set the PYTHONPATH variable for each without them colliding

brazen stirrup
#

good morning guys!
I'm looking for flask boilerplate(starter)
is there some recommendation?

tame viper
#

@brazen stirrup

brazen stirrup
#

@tame viper thank you for your recommendation

tame viper
#

πŸ‘Œ

idle osprey
#

im trying to input multi-lined strings into flask templates, but the " ` " keeps getting through the safe filter. Is there a prevent it

idle osprey
#

if i try .replace it sanitizes the sanitize

thorny scaffold
#
from flask import Flask, jsonify

app = Flask(__name__)

@app.route('/simplecrypter/<string:message>/<int:key>/<int:choice>', methods=['GET'])
def s_crypter(message, key, choice):
    alph = 'bILsNC3Jv1w2Vj6u4AhWMPDmBlQ7 rtKHZfEa9XFocpnY5eUGxdyzTkRSiO80qg'
    newmessage = ''
    out_message = {'message': newmessage}

    for c in message:
        if c in alph:
            pos = alph.find(c)
            if choice == 0:
                new_pos = pos + key % 63
            elif choice == 1:
                new_pos = pos - key % 63
            newc = alph[new_pos]
            newmessage += newc
        else:
            newmessage += c
    return jsonify(out_message)

if __name__ == '__main__':
    app.run(debug=True)
#

I am learning to build APIs using Flask

#

I am getting an error of index out of bound for newc = alph[new_pos]

#

can anyone who has knowledge on APIs in Flask check this and point me what am I doing wrong?

pearl kite
#

You may want

new_pos = (pos + key) % 63
#

That way the modulus operator correctly works on the whole position and not just the key part

#

(Same with the pos - key line)

thorny scaffold
#

yes Now it works but returns an empty string

#

Oh yeah

#

i have to add it to the dict first

#

stupid me

#

πŸ˜…

#

thank You @pearl kite

shrewd sand
#

Can i have 2 websites on the same server?

tame viper
#

yes

shrewd sand
#

@tame viper im confused why my second domain will not work

tame viper
#

okay

shrewd sand
#
server {
  listen 433;
  listen [::]:433;

  server_name code.mcadesigns.co.uk;
  location / {
    return 301 https://github.com/Sharpz7;
  }
}

server {
  listen 433;
  listen [::]:433;

  root /var/www/mcadesigns.co.uk;

  index index.html;

  server_name mcadesigns.co.uk www.mcadesigns.co.uk;

  location / {
    try_files $uri $uri/ =404;
  }

  error_page 404 /404.html;
  error_page 500 502 503 504 /50x.html;
  location = /50x.html {
      root /usr/share/nginx/html;
  }
}
#
IMPORTANT NOTES:
 - The following errors were reported by the server:

   Domain: code.mcadesigns.co.uk
   Type:   unauthorized
   Detail: Invalid response from
   http://code.mcadesigns.co.uk/.well-known/acme-challenge/DoriRmKpGoGWkz_jrFo0uPDvKVX6v5l7pectxlNesPs:
   "<!DOCTYPE html>
   <!--[if lt IE 7]> <html class="no-js ie6 oldie" lang="en-US">
   <![endif]-->
   <!--[if IE 7]>    <html class="no-js "

   Domain: mcadesigns.co.uk
   Type:   unauthorized
   Detail: Invalid response from
   http://mcadesigns.co.uk/.well-known/acme-challenge/TUc4rHuuANSLQRjgbSVNyhMsM_llXV7N1LePtVDLoQA:
   "<!DOCTYPE html>
   <!--[if lt IE 7]> <html class="no-js ie6 oldie" lang="en-US">
   <![endif]-->
   <!--[if IE 7]>    <html class="no-js "

   Domain: www.mcadesigns.co.uk
   Type:   unauthorized
   Detail: Invalid response from
   http://www.mcadesigns.co.uk/.well-known/acme-challenge/5yB3RrojzdCFTgQzWJJmuAp0VULxRwa3zXwMGQyxNVA:
   "<!DOCTYPE html>
   <!--[if lt IE 7]> <html class="no-js ie6 oldie" lang="en-US">
   <![endif]-->
   <!--[if IE 7]>    <html class="no-js "

   To fix these errors, please make sure that your domain name was
   entered correctly and the DNS A/AAAA record(s) for that domain
   contain(s) the right IP address.

#

Running service nginx restart produces no errors

tame viper
#

what's your domain configuration?

shrewd sand
#

Wait a sec

#

I think a friend of mine

#

Smashed the wrong number

#

When i typed it in

tame viper
#

hm

shrewd sand
#

That is the right IP 100%

#

@tame viper my friend added a extra 6

#

To the IP

#

lol

tame viper
#

oh okay

shrewd sand
#

In theory it should work now........

#

But it ain't

#

;/

#

Still 502

meager anchor
#

@shrewd sand Did you get let's encrypt to work?

shrewd sand
#

Yep

#

Says they are all registered

#

And restarting nginx made no errors

meager anchor
#

The 502 is returned by cloudflare?

#

Or your server?

shrewd sand
#

Server

#

Pretty sure

meager anchor
#

Are you visiting your website on HTTP or HTTPS?

#

your port 80 is closed

#

Oh, yeah, you don't have any listen 80s

#

Is that intentional?

shrewd sand
#

Yes

#

I have everything to 433

meager anchor
#

And you canβ€˜t reach your server on 443?

shrewd sand
#

No

#

It runs on the same server

meager anchor
#

Okay

#

hmhmmm

shrewd sand
#

xd

meager anchor
#

I mean

shrewd sand
#

I'm thinking website cache

#

But idk

meager anchor
#

You're listening on 443, but don't specify certificates, clients won't like that

shrewd sand
#

Ohhhhh

meager anchor
#

What

shrewd sand
#

I added certs

meager anchor
#

Okay

shrewd sand
#

dw

#
server {
  listen 433;
  listen [::]:433;

  server_name code.mcadesigns.co.uk;
  location / {
    return 301 https://github.com/Sharpz7;
  }

  ssl on;
  ssl_certificate /etc/letsencrypt/live/mcadesigns.co.uk/fullchain.pem;
  ssl_certificate_key /etc/letsencrypt/live/mcadesigns.co.uk/privkey.pem;

}

server {
  listen 433;
  listen [::]:433;

  root /var/www/mcadesigns.co.uk;

  index index.html;

  server_name mcadesigns.co.uk www.mcadesigns.co.uk;

  location / {
    try_files $uri $uri/ =404;
  }

  error_page 404 /404.html;
  error_page 500 502 503 504 /50x.html;
  location = /50x.html {
      root /usr/share/nginx/html;
  }

  ssl on;
  ssl_certificate /etc/letsencrypt/live/mcadesigns.co.uk/fullchain.pem;
  ssl_certificate_key /etc/letsencrypt/live/mcadesigns.co.uk/privkey.pem;

}
#

Wait a sec

#

error_page 500 502 503 504 /50x.html;

#

502 is covered

#

πŸ€”

meager anchor
#

NGINX is running, correct?

shrewd sand
#

Yep

meager anchor
#

The site is symlinked to /etc/nginx/sites-enabled?

shrewd sand
#

Or my other domain wouldn't be up

meager anchor
#

sudo nginx -T outputs these configurations?

shrewd sand
#

Yep

#

It outputs 2

meager anchor
#

Can you try telling nginx to listen on 80?

shrewd sand
#

Ok

#

And also tell cloudflare to stop auto-443 support?

meager anchor
#

Not sure

shrewd sand
#

No

#

Lets not get into how long this took me to do the first time ;D

#

What i am saying is

#

Cloudflare automatically changes http to https

meager anchor
#

Ah, I see

#

Do you get anything popping up in your nginx access or error log?

shrewd sand
#

@meager anchor got something

#

Disabled auto https

#

And listens to 80

#

You get this

meager anchor
#

What?

shrewd sand
#

How is it a https port when i say listen 80?

#

πŸ€”

meager anchor
#

Where did you put that?

shrewd sand
#

In the config

#

Like you wanted me to

meager anchor
#

In an existing server block?

shrewd sand
#

Can you try telling nginx to listen on 80?

#
server {
  listen 80;
  listen [::]:80;

  server_name code.mcadesigns.co.uk;
  location / {
    return 301 https://github.com/Sharpz7;
  }

  ssl on;
  ssl_certificate /etc/letsencrypt/live/mcadesigns.co.uk/fullchain.pem;
  ssl_certificate_key /etc/letsencrypt/live/mcadesigns.co.uk/privkey.pem;

}

server {
  listen 80;
  listen [::]:80;

  root /var/www/mcadesigns.co.uk;

  index index.html;

  server_name mcadesigns.co.uk www.mcadesigns.co.uk;

  location / {
    try_files $uri $uri/ =404;
  }

  error_page 404 /404.html;
  error_page 500 502 503 504 /50x.html;
  location = /50x.html {
      root /usr/share/nginx/html;
  }

  ssl on;
  ssl_certificate /etc/letsencrypt/live/mcadesigns.co.uk/fullchain.pem;
  ssl_certificate_key /etc/letsencrypt/live/mcadesigns.co.uk/privkey.pem;

}
meager anchor
#

you have listen 80 and ssl on there

shrewd sand
#

Ok, but i got nginx to give me a error

#

Thats good no?

meager anchor
#

I guess

#

What I usually do is have 80 redirect to 443

shrewd sand
#

Yeah ok

#

433 gives a 502 error from cloudflare

#

So my main server listens 2 433

#

This one to 80?

meager anchor
#

In your case, make an extra server block:

server {
    listen 80;
    listen [::]:80;

    server_name code.mcadesigns.co.uk www.mcadesigns.co.uk mcadesigns.co.uk;

    return 301 https://$server_name$request_uri;
}
#

Add that

#

Then change 80 back to 443

#

in your other configs

shrewd sand
#

It works

#

Ill add your changes now ;D

meager anchor
#

Is that with cloudflare?

shrewd sand
#

Cloudflare is providing partial https

#

Yes

meager anchor
#

ah

shrewd sand
#

@meager anchor what is that code actually solving

#

I don't see how it solves the problem

meager anchor
#

It was in response to you adding the listen 80 in the wrong spots, what I meant was to set up a redirect to https

shrewd sand
#

But i don't need to do that?

#
server {
  listen 80;
  listen [::]:80;

  server_name code.mcadesigns.co.uk;
  location / {
    return 301 https://github.com/Sharpz7;
  }

  ssl off;
  ssl_certificate /etc/letsencrypt/live/mcadesigns.co.uk/fullchain.pem;
  ssl_certificate_key /etc/letsencrypt/live/mcadesigns.co.uk/privkey.pem;

}

server {
  listen 80;
  listen [::]:80;

  root /var/www/mcadesigns.co.uk;

  index index.html;

  server_name mcadesigns.co.uk www.mcadesigns.co.uk;

  location / {
    try_files $uri $uri/ =404;
  }

  error_page 404 /404.html;
  error_page 500 502 503 504 /50x.html;
  location = /50x.html {
      root /usr/share/nginx/html;
  }

  ssl off;
  ssl_certificate /etc/letsencrypt/live/mcadesigns.co.uk/fullchain.pem;
  ssl_certificate_key /etc/letsencrypt/live/mcadesigns.co.uk/privkey.pem;

}
#

this is the config that is getting the server working

#

cloudflare is automatically converting to https aswell

meager anchor
#

ah

shrewd sand
#

So why does it break, when i make the port 433?

#

Should i have everything in one file?

#

Idk

meager anchor
#

as to "why does it break" I'm not sure, check the guide I linked, there is a client certificate configured there

#

and "should i have everything in one file", thats up to you, i have one file per http / https per domain managed via ansible

shrewd sand
#

Yeah

#

I just don't see why one domain is working

#

And one isnt

#

xd

#

When they have the same configs

#

@meager anchor followed that link

#

Set it all back up to port 433

#

Get the error.......

#

And the log is empty

#

;D

#

Really confused now.....

shrewd sand
#

@meager anchor do i have 2 processes using the same port?

#

Is that the problem?

meager anchor
#

Sorry, I'm somewhat busy, if two services try to use the same port then one of them will break, and if your nginx doesn't blarg something like [emerg] could not bind you're good

shrewd sand
#

It did!!!!!!

#

Yay!

idle osprey
#

is flask auto-converting strings to ints (if possible)?

vestal hinge
#

hey is anyone here good with dns?

#

nevermind πŸ˜ƒ

keen ore
#

hmm, how can i package a python flask app in a way that "normal" people can easily run it on their local machine

deep cave
#

buy a domain :P

#

it's a webserver. you should serve it on the web.

#

but if you really must, I guess you'd have to make an installer or something.

stark yarrow
#

Hey, I'm trying to build a form of a dynamic list of categories for product categorization. I'll be getting this information from a server dynamically. I'm trying to figure out the best way to do it.
eg: First the user selects a root category ('Eletronics, Sport and Fitness, Beauty, ...'). Then if it has children categories, I need to create a new list of values, with its children.
For example, if I select Eletronics create a new list with 'Smart TV', 'Home theather', 'Sound System', etc. Then if the new chosen category has childrens do it again until it doesn't return more categories. This will all be pulled from a json file provided by the request to the server.
I'm using Flask but I guess it wouldnt work but I still need to be able to retrieve the post data in Flask. I could do this using JavaScript but I don't how would I do it properly.
Because I'm dealing with over 150 thousand categories and subcategories I don't know the best way to handle this.
Can anyone give me a direction? I have a picture of exactly what I want.

native tide
#

@keen ore host it online

#

on heroku

naive wing
#

Hi guys

#

What is the best way to schedule a python function for flask?

native tide
#

use django

grand badge
#

stick with flask if you prefer it

meager anchor
#

@naive wing depends on what you want to do. I don't think that flask has something built-in for that. You might be able to use something like at or cron. would be good to get some more info

#

@native tide your "answer" is absolutely useless. if you plan to help, provide some useful information, django does not have any built-in way to schedule tasks and even if it had, your message doesn't provide any useful arguments that would help in solving the original question

native tide
#

When i want to do web dev with python should i just dive right in django or somethig else. Or learn python itself first?

#

And is django for example able to make a Full website without any other language?

meager anchor
#

you should learn Python itself before taking on a bigger project, yes

#

depends on what you define as a "full website"

#

for front-end you generally need at least HTML

digital bluff
#

@native tide if you want to make a website with a python framework, you should probably learn python first

brave otter
#

heyooo

#

anyone in here a react guru? or even moderately good at react? lol

#

I mean I know this is a python channel but if it helps this is in a django application w/ a react front end πŸ˜ƒ

meager anchor
#

Don't ask to ask

brave otter
#

Sorry .. it's just a lot to type out in a python channel if there's no one here familiar w/ react that's all.

#

This is just one of the more active discords and I know developers tend to be multi-disciplined lots of times.

olive wharf
#

What is the correct way to layout a navigation menu if i have html <header> <nav> <ul> <li></li> <li></li> </ul> </nav> </header> and want each li element to be a full on box to be clickable

#

Do i put the link tag inside the list element with a span or something to set the boundaries, or wrap each list element in a link tag

#

I found trying to style a link tag a with a clickable box... to be weird

#

While im at it, is it more semantically correct to have a logo/gotohome-image be within nav, or just header

proper hinge
#

I think either way is fine - logo in header or in the navbar

#

generally i dont bother wrapping the nav in a header element

#

I have only found it to be redundant in my experience

olive wharf
#

I thought i'd create a generic nav bar template i imported to all other templates

proper hinge
#

but I suppose it depends on your design

olive wharf
#

So figured i'd do it as correct as possible to just be.. correct

#

And if i put the logo outside of nav, header kind of makes sense

#
    <header>
        <img src="static/logo.png">
        <nav>
            <ul>
                <li></li>```
#

I'll just do that

#

Any idea on a good practice for nav bar <a> tag placement though?

proper hinge
#

There really is no correct way with these semantic tags imo

olive wharf
#

True, but it does effect the google algorithm

proper hinge
#

there are various combinations which all can make sense

#

well that's a different story

olive wharf
#

Stuff like just having a header tag bumps you up quite a bit.

#

So i just kind of want to make it a habbit

proper hinge
#

I only use is if I really need it as a list. I usually just go with divs or spans at that point

#

May I ask, do you really need a ul for your navigation?

#

sorry my internet is cutting out 😑

olive wharf
#

where it seems like a list, a ul/ol makes sense

#

The web design course I'm taking heavily focuses on correct semantics as well

#

So stay away from divs

dusty spruce
#

Ordered lists are better for navbars

olive wharf
#

and spans for inline styling

dusty spruce
#

In my opinion

olive wharf
#

Any particular reason to why?

#

I mean, sure.. It is ordered in a sense

#

But it's order does not matter(?)

#

God I have a feeling this course is going to hurt me in the end yoj

proper hinge
#

Proper semantics is great and all but I don't think the list elements suit navbars very well. Unless it's vertical and you're not hiding the bullet points. Even then, I feel like the lists should be reserved to text most of the time

dusty spruce
#

But it has pweddy liddl numbers

olive wharf
#

I'm stripping the styles, completely

#

There wont be a number, nor bulletpoint

dusty spruce
#

Lol sorry

#

I have moments

olive wharf
#

Point of the list is to the semantics of showing, things are listed in some fashion here.

#

But.. eh

#

A list was correct according to my lecturer at least

dusty spruce
#

I am an '''python expert ''' at html

#

Nop.

#

Just html and python seperately

olive wharf
proper hinge
#

I like the alternative

#

where you just have the anchor elements directly in the nav

#

much cleaner looking

#

the list just feels completely redundant

olive wharf
#

wtf is that media query

#

It became smaller, the bigger i made the window

proper hinge
#

it's just a dummy wrapper around what you actually want to display

olive wharf
#

πŸ‘πŸΎ

dusty spruce
#

Do you do scripts in or out of the body tab?

#

I do them out

olive wharf
#

I dont have scripts atm

#

A side from the blocks for content and header

proper hinge
#

Main thing to take away from this is that there isn't a set in stone way of doing things

olive wharf
#

True

proper hinge
#

as you can see there are various arguments for how to do this

olive wharf
#

But I do want to do what pleases the lecturer the most weSmart

proper hinge
#

based on the csstricks link

#

I agree with the writer

#

you do you

dusty spruce
#
<script>
 var as = true;
</script>
#

I keep on doing the python at the beginning

#

Sorry

#

But no scripts!

#

That's appauling

olive wharf
#

No, I wouldn't write script blocks

#

If that's the question

#

I import own js files

dusty spruce
#

They are easier though

olive wharf
#

Never found it easier, nor cleaner

dusty spruce
#

Clean - Ness is an issue

olive wharf
dusty spruce
#

I was never taught how to import

olive wharf
#

Copy paste the line, it's the project for my last web dev course

dusty spruce
#

But that is owing toe self teaching myself

proper hinge
#

@olive wharf By the way what do you find weird about styling an anchor as a button?

#

Like implementation wise

#

or semantically?

olive wharf
#

The part where I specify width and height on the <a> tag it self

#

It didnt seem to actually gain the height, nor width

dusty spruce
#

I self taught myself python, c#(didn't want to, but Unity was like heyyyyyyyyy), js, java, Pascal and a bit of c++

proper hinge
#

I've managed to successfully do it

olive wharf
#

Only if i wrapped it in, say a div would the entire block act as a link

proper hinge
#

I used flex containers though

#

flex all the things

olive wharf
#

I believe i did as well

proper hinge
#

here's is what I had html <nav> <a href="" class="nav-link current" id="nav-link-1">Item 1</a> <a href="" class="nav-link" id="nav-link-2">Item 2</a> <a href="" class="nav-link" id="nav-link-3">Item 3</a> <a href="" id="button-close">❌</a> </nav>

olive wharf
#
<li class="project">
    <a class="projectLink" href="project1/sub-directories/natalie.html">
        <figure>
            <img class="projectImg" src="visuals/treehouse.jpg" alt="broccolitreehouse">
            <figcaption class="projectCap">Lab 1. - Fun Facts</figcaption>
        </figure >
    </a>
</li>```
#

Wait..

#

Nvm?

proper hinge
#

This was the scss for it

olive wharf
#

I was sure I ended up with the a outside of the li tag

proper hinge
olive wharf
#

huh

#

Guess I had no problems then.

dusty spruce
#

Couldn't you use a <form> <input type="button" id="egid"> </form>

proper hinge
#

lol no

dusty spruce
#

For examplw

proper hinge
#

you wouldnt use forms for nav bars

olive wharf
#

Forms isnt really made for navigation bars :v

dusty spruce
olive wharf
#

pls no spam

dusty spruce
#

Three limit

#

More is spam

proper hinge
#

@olive wharf ok for your site it's different cause it isn't just a simple nav bar

#

I wouldn't only use an anchor there obviously

olive wharf
#

True

proper hinge
#

Even though it can work

olive wharf
#

But i had issues with the entire block being a link

#

wait, no that was project 2

#

ah yeah

#
        <nav>
            <ul>
                <li>
                    <a href="#">Series</a>
                </li>```
#

Where only text is click-able

proper hinge
#

🀒

dusty spruce
#

Ok

#

I

#

Am going

proper hinge
#

c ya

dusty spruce
#

Wait for it

proper hinge
#

I remember I also encountered that issue

#

there is a fix for it, just dont remember it

olive wharf
#

Guess ill look for that then

dusty spruce
#

Send random people friend requests

proper hinge
#

some way to change the clickable area for the anchor

olive wharf
#

I'd hate to wrap list elements with a tags

#

But I am questioning one thing about the post you sent btw, mark

proper hinge
#

and that would be'

olive wharf
#

Does this say.. it made it better, or worse for screen readers

#

Cause that's pretty much the edge case here

proper hinge
#

Not sure either

olive wharf
#

And i should stop reading things from end to start

#

Lol

#

if it just reads it like that..

#

See no point

proper hinge
#

time to fight your instructor about it

#

square up

olive wharf
#

I will

#

trust me :P

proper hinge
#

yeah

olive wharf
#

Shame I can't use any form of scripting / backend tools for the course

#

But this gives me a bit of practice at least

proper hinge
#

Just read an interesting thing

#

If your logo links to e.g. the home page

#

it'd make sense to put it inside nav

#

otherwise, don't

olive wharf
#

Bruh

#

I've been stuck on that.. for ages

proper hinge
#

since it doesnt navigate the user to anything

#
The nav element represents a section of a page that links to other pages or to parts within the page: a section with navigation links.```
olive wharf
proper hinge
#

Doesn't look like you have it linking to anything

olive wharf
#

not yet, no

proper hinge
#

Then so far, I'd say you did the right thing with the header

olive wharf
#

I'll still keep the header

proper hinge
#

if it's clickable I'd move it inside the nav bar

olive wharf
#

I believe it helps screenreaders

#

and other .. stuff

proper hinge
#

πŸ€”

olive wharf
#

easier to copy paste πŸ˜‚

#

... does that help me? lol

#

it's fighting my case

proper hinge
#

well

#

they can navigate nav too

#

just like header

olive wharf
#

Yeah

#

That's what I ment

#

Maybe I'll use header as .. the head of the sites content

#

like
nav
header
main
footer

#

Anywho thanks for your time @proper hinge Imma hit the hay

proper hinge
#

gn

hearty birch
#

what does reqparse do in flask

kind steppe
#

Flask doesn't have anything called reqparse

hearty birch
#

ahh it's in flask-restful nvm

#

anyway, i was wondering what would be the best way to check if a user who is sending a POST request's json file is in the right format

#

I want it like this
{
"username": "mushy"
}
anything else it would reject and return a 404

#

on flask btw

kind steppe
#

add a list of expected fields and if one is not there, raise a NotFound or BadRequest exception

tame viper
#

(also, don't return a 404, that's for when they try to access a page that doesn't exist)

#

422 might be a good one, though 400 is also fine (but too broad imo)

kind steppe
#

if you are looking up a user (which that request body might be doing) 404 should be fine

hearty birch
#

yeah I was looking up a user

kind steppe
#

in that case, 404 is appropriate

tame viper
#

but a bad POST request format calls for 400/422 does it not?

kind steppe
#

422 would probably not be applicable juan

#

well

#

it might be

hearty birch
#

add a list of expected fields to what

kind steppe
#

hmm actually

#

it might be the one yeah

#

a list of expected fields in the POST request

tame viper
kind steppe
#

we made them

tame viper
#

oh huh okay

kind steppe
#

i think

tame viper
#

i know you made their checks

#

but i swear schemas are from somewhere else

kind steppe
#
@app.route("/search", methods=["POST"])
def search():
    expected_fields = ("username",)
    for field in expected_fields:
        if not request.json.get(field):
            raise werkzeug.exceptions.BadRequest(f"The required field, {field}, was not found in the request")
#

something along the lines of that

#

I just threw that together in Discord so I can't confirm it works

tame viper
#

yeah, something like that ought to do it.

hearty birch
#

yeah I was thinking something like that

tame viper
#

but if you do that a lot, i recommend putting it in a decorator like we have

hearty birch
#

but i would have to do that for every endpoint right?

kind steppe
#

if you are using it across requests it wouldn't be hard to put that into a decorator

tame viper
#

2QUICK

#

sorry

hearty birch
#

ah okay

#

🀣

#

how did you guys do it?

kind steppe
hearty birch
#

also, when doing
request.data
it just returns an empty byte when printing
but when I do request.get_data().decode('utf-8) it returns it normally

#

whys that?

#

well

#

whats the difference between request.data and request.get_data()

#

is a better question

tame viper
#

"request.data Contains the incoming request data as string in case it came with a mimetype Flask does not handle."

kind steppe
#

yeah, if the data has been parsed (e.g. placed into request.json) I don't think it appears in request.data

tame viper
#

which is.. not good design, imo

kind steppe
#

It is a little odd

tame viper
#

inconsistencies make me upset

hearty birch
#

oh so I should be able to access it with request.json

tame viper
#

certainly

hearty birch
#

naisu

kind steppe
#

if the data is json, request.json will be a dictionary

hearty birch
#

yeah it's a json

tame viper
#

if the data isn't json, you might get a fat error though

#

so i'd watch out for that

hearty birch
#

hmmm

#

ill pretend theres no error for now

#

just tryna get something to work πŸ˜„

tame viper
#

nah, get the error sorted now while you can

hearty birch
#

what error might be thrown?

tame viper
#

don't know, give it a go :P

#

return a 422 response if it's not json, though

hearty birch
#

wait, doesn't flask do it already

tame viper
#

oh

#

it might

kind steppe
#

I think 400 should be used for not json

hearty birch
#

ill check actually one sec

tame viper
#

oh hmm

kind steppe
#

because 422 suggests that the syntax is correct but the instructions could not be carried out

#

400 suggests that the request is invalid

tame viper
#

422 is Unprocessable Entity

#

but yeah

#

400 makes sense too

kind steppe
#

yeah, but looking it up seems to show that the syntax is valid for 422 errors, it just can't be processed

tame viper
#

but really, 400 can work for all 4xx errors, it's just broad

#

it's the Exception of exceptions

kind steppe
#

yeah

tame viper
#

"sorry, i don't know how to say this, so.. 400 Bad Request"

#

what's the highest status number a HTTP response can have?

hearty birch
#

oh hm

#

so i used request.json

#

and it's returning a nonetype now

#

omg

#

nvm im an idiot

tame viper
#

oh hey, that makes two of us

hearty birch
#

indeed

#

why arent u asleep juan 😎

tame viper
#

my dude, i slept ages

#

after being awake for 34 hours

native tide
#

Good evening. In which Channel can i post question for discord api?

hearty birch
#

oh yikes, gotta fix up the schedule school opens soon πŸ‘€

native tide
#

Ah sorry

#

Now i have seenchannel

hearty birch
#

ok πŸ˜„

tame viper
#

questions about using discord.py can be asked in the dedicated channels, but if it's a general question about the discord API then here should be fine

#

@native tide

hearty birch
#

So what would I return if they have a wrong token

#

like arent authroised

tame viper
#

i think 403 Forbidden

#

wait no

#

401 Unauthorized

hearty birch
#

Okay so I should retun 403 forbidden if they dont have a token in their header, and 401 unauthorized for wrong token

tame viper
#

401 for both

#

i believe

#

403 is when they try to access a file that the server doesn't have permissions to view, for example

#

@kind steppe can you confirm?

hearty birch
#

ah okay, thanks

#

thanks guys

#

great help

kind steppe
#

I can't remember exactly

#

One of them is you'll never have permission, one is that you aren't logged in iirc but i may be wrong

strange thorn
#

401 means authentication is possible but has failed or not been provided
403 means server noticed request but won't respond to it even if you provide login credentials

kind steppe
#

That's the one

native tide
#

finished my forum software πŸ˜„

olive wharf
#

Can i have global templates in django?

#

If i wanted to create multiple apps, with their own respective templates etc, and have them all inherit a global navigation bar from the main projects templates

meager anchor
#

Yeah!

#

I'm doing exactly that in our django rewrite

#

Basically, by default the template loader looks for the app paths

#

However, you can add the projects path or whatever else you like

olive wharf
#

Ay yeah I figured out through a bit of trial and error c:

olive wharf
#

Ah that's the magic

#

but yeah, It generated a templated folder in the projects dir so I plonked by base template there, and could use it anywhere in my apps

#

actually... is it working? thinkies

#
<body>
    <nav class="nav-bar" role="navigation">
        <img id="logo" src="static/logo.png" alt="Logo of website">
        <a class="nav-element" href="/">Home</a>
        <a class="nav-element" href="/projects/">Projects</a>
        <a class="nav-element" href="/blog/">Blog</a>
        <a class="nav-element" href="/about/">About</a>
        <a class="nav-element" href="/contact/">Contact</a>
    </nav>
    <header>
        
        
    </header>
    <main>
        
        
    </main>
    <footer>
        <span>Copyrighted &copy; Floppy-Mc. Flopson</span>
    </footer>
</body>
</html>


    <h1>Hello</h1>``` I got this
#

from doing this ```html
{% include "base.html" %}

{% block header %}
<h1>Hello</h1>
{% endblock header %}

#

with a base like this html <header> {% block header %} {% endblock header%} </header> <main> {% block main %} {% endblock main %} </main> <footer> <span>Copyrighted &copy; Floppy-Mc. Flopson</span> </footer> </body>

olive wharf
#

Uh~

meager anchor
#
{{ block.super }}
#

Although I don't fully understand what I'm looking at here

olive wharf
#

What's the difference of include and extends here?

meager anchor
#

You have a base and a navbar template?

#

Include just ... includes the thing

#

Extends allows you to change blocks and whatnot

olive wharf
#

I have a base which is basically navbar + footer with blocks for header and main

#

Oof, i probably want extends then

#

Ah yeah, there we go

#

Didn't need super c:

#

just the mistake of using include over extends

raven harbor
#

please help me to identify the error

meager anchor
#

the error is pretty descriptive

#

did you write your migration yourself?

raven harbor
#

no sir

meager anchor
#

so where does the pages app come from?

hearty birch
#

@tame viper having trouble writing the decorator to check the fields

#

I haven't written a proper decorator before, but I have this so far

def parse_fields(expected_fields):
    def field_decorator(func):
        def func_wrapper():
            print("Called fuction wrapper.")
            data = request.json
            for field in expected_fields:
                if field not in data:
                    return BadRequest(f"The required field, {field} is missing.")
        return func_wrapper
    return field_decorator

and trying to call it in my route like so

@app.route('/api/v1/user/', methods=['POST'])
@parse_fields(["username"])
def user_info():
    data = request.json
    user = User.query.filter_by(username=data['username']).first()
    if user is None:
        return BadRequest(f"That user does not exist.")
    user_data = {
        "uuid": user.id,
        "username": user.username,
        "email": user.email,
        "first_name": user.first_name,
        "last_name": user.last_name,
        "last_seen": user.last_seen,
        "about_me": user.about_me
    }
    return jsonify(user_data)
raven harbor
#

@meager anchor ya sir i created it using startapp command

meager anchor
#

ok. can you show us the migration?

hearty birch
#

Anyone have any ideas?

#

The decorator works for the most part, as when I enter an incorrect field in the JSON post request, it picks it up and throws a badrequest

raven harbor
#

how can i show sir

hearty birch
#

however, when it's correct, I get this:

TypeError: The view function did not return a valid response. The function either returned None or ended without a return statement.
meager anchor
#

you never actually return the result of the function in the decorator

#

try

def parse_fields(expected_fields):
    def field_decorator(func):
        def func_wrapper(*args, **kwargs):
            print("Called fuction wrapper.")
            data = request.json
            for field in expected_fields:
                if field not in data:
                    return BadRequest(f"The required field, {field} is missing.")
            return func(*args, **kwargs)
        return func_wrapper
    return field_decorator
hearty birch
#

what would this do?

raven harbor
#

where i can find those migrationns

hearty birch
#

I just want it to check if theres a bad request, if there isn't then the view function can continue

#

ill try this though one sec

#

yeah that worked @meager anchor thanks, could you explain what that did? if you dont mind

meager anchor
#

@raven harbor pages/migrations

#

@hearty birch your code replaces your original request function with func_wrapper, which returns None if all fields are present

#

and flask expects responses to be returned

hearty birch
#

is this the default behaviour?

#

hmmm

#

this is confusing

meager anchor
#

well, a view gets called in response to someone visiting a URL

#

what would you expect a view to do?

hearty birch
#

no i mean the decorator, why will it not just continue with the function instead of returning None

meager anchor
#

because you don't call it

hearty birch
#

ah ok

#

say I have a backend in Flask and frontend react, how would I handle things such as logging in?

raven harbor
#

please tell me how to bring that second card right to first card please

knotty lark
#

There are many ways to deal with layout in CSS. One solution is to set the cards to have a display: inline-block property

raven harbor
#

@knotty lark can u edit a lil bro so that i can understand.. please

knotty lark
#

Do you know CSS at all?

raven harbor
#

ya i know css ..

knotty lark
#

you can add display: inline-block; to the style tags of your cards and it should do the trick.

raven harbor
#

but im new to this ide and pythoon codes so.. feels unusual bro

#

okay ill do that and get back to u in a min ....bro

meager anchor
#

I'm not your "bro". Does pages/migrations/__init__.py contain anything?

raven harbor
#

@knotty lark thanks for the idea .. it worked

#

@meager anchor sorry if that was wrong please tell me how can i address u with

#

@meager anchor nothing it is empty

meager anchor
#

just "Volcyy"

#

use -v 3 when running the migrate command

#

and check the output

raven harbor
#

@meager anchor sure

#

@meager anchor i didnt use migrate command yet

meager anchor
#

you gotta migrate your app before you can run it properly

hearty birch
#

Ah, i've run into a problem with the decorator

#

if I use it for another route

#

AssertionError: View function mapping is overwriting an existing endpoint function: func_wrapper

raven harbor
#

i used ---> python manage.py migrate this is the only time i used migrate command

#

@meager anchor is there any command that i need to use to fix it..?

hearty birch
#

so it's thinking that func_wrapper is an endpoint function 😠

hearty birch
#

yeah I can't get this to work

native tide
#

Can anyone here help me with something?

#

im stuck on it and ive tried everything.

#

tag me if you can

knotty lark
#

!t ask

lavish prismBOT
#
ask

Asking good questions will yield a much higher chance of a quick response:

β€’ Don't ask to ask your question, just go ahead and tell us your problem.
β€’ Try to solve the problem on your own first, we're not going to write code for you.
β€’ Show us the code you've tried and any errors or unexpected results it's giving
β€’ Keep your patience while we're helping you.

You can find a much more detailed explanation on our website.

native tide
#

nvm i fixed it

#

stupid error

#

didnt indent

#

lol

#

When I try to delete a entry from my model I get this 'bool' object is not callable

#

any ideas?

olive wharf
#

How are you trying to delete it

native tide
#

In the database

#

in django admin

knotty lark
#

Show us the code..

olive wharf
#

If it's django admin..?

#

What does your model look like

native tide
#
    name = models.CharField(max_length=30, unique=True)
    description = models.CharField(max_length=100)

    def __str__(self):
        return self.name```
#

Thats my model

#

I got it.

raven harbor
#

i dont know how this nav bar changed like this . i didnt do anything

knotty lark
#

@raven harbor It's functionality provided by the bootstrap template you're using. On smaller resolutions the menu bar collapses into a drop down.

raven harbor
#

but previously it was working fine is there any way to bring them back in position

knotty lark
#

Reset the zoom level.

#

You're way zoomed in lol

raven harbor
#

lol sorry for my stupidity .. those are completely new for me...

knotty lark
#

Ignorance != Stupidity πŸ˜ƒ that's how you learn hyperlemon

raven harbor
#

can u suggest me any tutorial to learn using bootstrap and font-awesome on django..

knotty lark
#

Well they're seperate topics from django, just visit the bootstrap website and the font-awesome website πŸ˜› They're just things you use in your client side html/css

raven harbor
#

But the code is different than normal html page to python html page so im confused.. I hope soon I'll learn

knotty lark
#

Well, there are some embedded statements in it because you're using a templating system but it's still just regular ol' HTML outside those {% %}s

queen needle
#

I think there might be "helper" modules for bootstrap on Django just like Flask has the (outdated) flask-bootstrap

#

Google will tell

idle osprey
#

is there a difference between flask.escape and flask.Markup.escape

raven harbor
#

is my code for preloader right?

olive wharf
#

Tias?

raven harbor
#

? cant get u ...

olive wharf
#

Try it and see

raven harbor
#

It didn't bro I got a white screen then nothing happened after refresh I got my page normally

patent aspen
#

how good is python for the backend of websites

digital bluff
#

if u mean django/flask, it's good

queen needle
#

@patent aspen mind-blowingly good

#

even besides django/flask there are several valuable web frameworks depending on your needs: aiohttp, tornado, falcon, hug

digital bluff
#

oh yea, aiohttp, tornado are both good too

#

dunno about the others

raven harbor
#

please help me with that preloader code

digital bluff
#

thats css..

#

how are we supposed to help

queen needle
#

@idle osprey flask.escape is pulled from jinja2 which in turns imports it from the markupsafe module.
Markup.escape is basically a wrapper around the markupsafe.escape function as its docstring says:

    @classmethod
    def escape(cls, s):
        """Escape the string.  Works like :func:`escape` with the difference
        that for subclasses of :class:`Markup` this function would return the
        correct subclass.
        """
        rv = escape(s)
        if rv.__class__ is not cls:
            return cls(rv)
        return rv

(might as well add the whole code)

patent aspen
#

@queen needle Cool! Thanks

raven harbor
#

okay thanks..

digital bluff
#

@raven harbor ur welcome. come back next time with useful information and we may be able to help.

raven harbor
#

sure im learning python from 2 days and i need to konw lots of infos from u all ill be back when i stuck with anything complicated

digital bluff
#

i dont have idea what you said, but the code you posted was css, not pythoh

raven harbor
#

im new to python and i need to know lots from u all

#

may i know that can i use sql server with python ? or any specific database to use

digital bluff
#

you want to know what database you can use?

raven harbor
#

S sir

digital bluff
#

any of 'em, pretty much

queen needle
#

Last time I tried MS SQL Server with python, the modules worked "meh" and didn't support all the features, so I wouldn't recommend that one

#

For the rest, MySQL, postgre, mongo, all work finely so break a leg

#

It was 3 years ago but I wasn't satisfied with either pymssql or pyodbc

raven harbor
#

Then I'll stick with my SQL ..

#

By any chance can I view my website in my phone .. while developing itself..like local hist

#

Host*

tame viper
#

run the site on 0.0.0.0 instead of localhost or 127.0.0.1, then connect to your computer's local IP from your phone. it must be on the same network though.

raven harbor
#

πŸ€‘

native tide
#

do i need to include the app? (django) i ran the program with including and without including and both worked..

grand badge
#

is that an app you created yourself? @native tide

#

oh i see that you are following thenewboston's django tutorial

#

include it

native tide
#

yeah.. i do

#

Ok now i know why i need to include it

#

because if i do not it won't be read by the database and the thing won't show up on the website

#

but thanks! @grand badge

grand badge
#

np

raven harbor
#

i cant find login page on my screen where i went wrong ..i think i missed some python code

digital bluff
#

not exactly super helpful, you should post the backend code

#

why is your file icon /*

raven harbor
#

sorry to ask but can u please tell me how to find backend code and whats it?

#

i got it i was missing {% block conent %} now its fine

digital bluff
#

if you dont know what your backend code is, how on earth did you get that to run?

raven harbor
#

im learning things now and ill soon understand things like this situations

elfin trench
#

so i wanna use python for back-end but javascript for small scripting stuff, so im not sure how would i connect the python stuff to the front end html, would I do this with django or idk.. i'm experienced with HTML and CSS stuff but idk where to start for the back-end and how to connect it

neat nest
#

django, flask, sanic, aiohttp, the standard library http.server...

#

all of these are viable options, which you pick will depend on the particulars of your project

#

http.server is great for playing around with simple request handling and building it yourself from the ground up, Flask is a very well-documented framework that makes routing and handling various kinds of requests very easy

#

Django is a much larger (and we often call it "more opinionated") framework but if you'd like to start with it it's also very well documented

elfin trench
#

someone told me (idk if this is true) but u can connect python to node.js

#

or something..?

#

is that true xD

neat nest
#

I'm sure there's a myriad of ways. I don't see why you'd want to do that in the general case

elfin trench
#

all of these still use HTML, CSS, and JS right?

neat nest
#

they're just HTTP servers, they don't care what kind of file they server

elfin trench
#

oh

neat nest
#

HTML, CSS, JS, PNG

#

that's up to you

elfin trench
#

hmm the problem is i dont know which one to pick xD

neat nest
#

but yes, all these frameworks have mechanisms for sending that across, and some have templating engines for generating HTML

#

well, what's your project?

elfin trench
#

its like a multi-purpose website

#

like to show what i've made

#

login system to sell stuff

#

maybe stats from other APIs..?

neat nest
#

my personal recommendation would be to start with Flask, then

elfin trench
#

and whys that? just asking so i could learn more

neat nest
#

it's very easy to get started, it's got so much documentation it's not even funny, and it can be connected easily to robust server software like Apache and Nginx

elfin trench
#

what about the other ones? can they do the same?

neat nest
#

Django is not as easy to get started with, but yes. Sanic and aiohttp are both asyncio-based and therefore probably not suitable for someone just getting started, but also yes

#

and those are just the ones I'm most familiar with

#

there's other stuff out there

#

Flask, though, is really the golden child of beginning web development, and it's even professionally viable

#

I don't think you'd regret working with it

elfin trench
#

alright then

#

thnx for the tips

neat nest
#

πŸ‘

elfin trench
#

oh one more thing, where do u think i should start?

#

lol

#

like a website or vid

neat nest
#

I'm not sure what you mean by vid, but if you mean to show off your work, I feel like building a website is more development relevant than a video

#

plus it's very easy to update a website and a little harder to update a video

elfin trench
#

no like tutorial

#

xD

#

sorry to confuse ya

neat nest
#

oh, I mean, I bet Flask has a Quickstart section

elfin trench
#

o.0

#

found it

#

xD

#

ok thnx a lot

neat nest
#

sure

elfin trench
#

so while looking at the flask documentation whats the difference between a module and package

neat nest
buoyant ledge
#

Just as a heads up Corey just uploaded a huge video series on Django

neat nest
#

oh that's right! have you seen any of it?

elfin trench
#

oh

#

its like java GWfroggyPepoThink why didnt i think of that

#

so when i create a package would i put in __init__.py would it just be like all the pages or what

#

i just want to have good practices with Flask and stuff @neat nest

queen needle
#

Wait somebody actually made a module called Sanic?

#

Dank memes in my pypi?

grand badge
#

!t

lavish prismBOT
#
**Current tags**

Β» ask
Β» classmethod
Β» codeblock
Β» enumerate
Β» except
Β» f-strings
Β» global
Β» iterate_dict
Β» listcomps
Β» no-dm
Β» or-gotcha
Β» pep8
Β» resources
Β» traceback
Β» with

grand badge
#

oh damn it

#

wrong channel

#

sorry about that

raw seal
#

Um! Hi! I've been developing a small CMS with flask for me and two other people to use, it has posting, searching, and a WYSIWG editor for the two people who didn't work on the code side of things. I wrapped up the app and tried to set it up on digital ocean using NGINX and Gunicorn, but it seems like my search method [Elasticsearch] isn't working at all, even though it's on the VPS and running. However, that's not my only problem, logging in doesn't save across pages on the VPS, but it does in the development environment. I'm not sure what's going on, honestly. I'm not getting any console errors on the droplet, and I'm not sure if NGINX is throwing errors because I don't know where to look for those.

Everything works perfectly in the development environment, so I'm not sure what to do.

elfin trench
#

for some reason when i open my __init__.py it doesnt use the stylesheet but when i open my index.html it uses the stylesheet

#

whys that

raw seal
#

Where are you linking your stylesheet?

elfin trench
#

i put it in the same place where my html file is @raw seal

grand badge
#

what framework are you using? @elfin trench

knotty summit
#

@elfin trench It seems you include static files incorrectly so server can't find them. Check you browser console for 404 errors for static files. Also I would recommend flask mega tutorial for you https://blog.miguelgrinberg.com/post/the-flask-mega-tutorial-part-i-hello-world It is better for beginners and still provides information about best practices. I think flask quickstart requires a little more experience in web-development and web-frameworks

elfin trench
#

@knotty summit i got that but now my CSS file can't get a image

#

and i have the image in the static folder

#

btw im using Flask

native tide
#

Is there anyone here who wouldnt mind helping me with dynamic fields in wtforms within a flask app?

native tide
#

Hi i'm using wtforms, i want a DecimalField to be separated by comma, not dot. I guess I have to insert number_format but I don't get how

raven harbor
#

this is my problem

polar wasp
#

@native tide i don't know about wtforms but maybe look for locale based features

raven harbor
#

i cant change the logo of a template .. the same logo remains after deleting the logo from the location .. what may be the reason. it works fine in html file but when i use this in python that problem occers

polar wasp
#

@raven harbor did you restart it?

raven harbor
#

no please hold on ill tell u after restarting

polar wasp
#

i meant just restart the python script, not your computer

#

maybe also do a hard reload in your browser

#

(shift-f5 or ctrl-f5)

raven harbor
#

done but the same remains

#

ill send a pic

nocturne plover
#

find . -name lg.png and file $path

#

It may not be at that path

#

or it may be broken

raven harbor
#

ya its in path

#

no problem with that file

#

i found something that i cant keep new logo which i add to the folder but i can keep existing file in the folder without any issue why is it so

nocturne plover
#

Is it being served with a bad MIME?

vestal hinge
#

ah wtf why why hasnt my dns updated in 2 days?

native tide
#

@polar wasp I figured out that there isn't a way to do that. I had to manually change it

brittle copper
#

I have a model in django
And I'm ordering it by some field like

Title.objects.get(whatever).entry_set.objects.order_by('points')

Everything is good so far
From this query set
I want to have the object that has pk=x
The previous of that object in the same order
And the next in the same order

#

So long story short

#
Title.objects.get(whatever).entry_set.objects.order_by('points')

is the query set

Entry.objects.get(pk=5)
``` is the object
 I want the next Entry object inside the queryset relative to the object I have
grand badge
#

I'm not sure what I asking for

brittle copper
#

I can't make it more clearer

grand badge
#

Try objects.all().order_by("points")

#

Lemme go on compooter

brittle copper
#

That's just a query set

#

I want to have the next item in a query set given an item as reference point

#

[1,3,8,2,7,0] and given item 2, I want to get 7

vestal hinge
#

you could do limit 2 and go from there?

brittle copper
#

I've never heard of that

#

Is that queryset.limit or something like that?

#

Oh just getitem syntax

#

But then I can't know if the object is in that part or not

patent aspen
#

can anyone recommend me a good tutorial on how to get started with the backend of websites using ptyon

#

python*

patent aspen
#

thanks

brittle copper
patent aspen
#

which would u recommend, flask or django

brittle copper
#

They serve slightly different purposes, django while is giving you lots of tools you need out of the box has little options in which where you can make it more customized

#

To customize it, you need to work harder than you'd in flask, but in flask you can't get a huge website up and running as fast as in django

#

But in total vibora is faster than both, but is async so you need to know async

patent aspen
#

Hm

#

alright

#

thanks

brittle copper
#

Rewriting my question

Title.objects.get(whatever).entry_set.order_by('points')```

from this query set I want to get the next object after `Entry.objects.get(pk=x)` and the object is definetly inside the queryset
meager anchor
#

what is x? the ID of the first thing returned by that query?

brittle copper
#

Not the first, just a random one that sure is inside the query

#

The actual query is something like

#
def _get_queryset(self):
    entry = Entry.objects.get(pk=self.kwargs['pk'])
    self.entry_cache = entry
    queryset = entry.title.entry_set.order_by('points')
    return queryset
def get_object(self):
    return self.entry_cache```
#

And as extra context to the template, I want to include the next and previous entries inside that queryset

raven harbor
#

this is the actual html code.. and i can change images in this

#

this is the python code and here i cannot change images

#

the image that works with html is not appearing in python.The images came with the template only apearing

#

even i delete them in the source its appearing when i use the name of the file

native tide
#

Hey guys, i have the: base.html
and inside of it there's a code in the middle of the page with:
{% block content %} {% endblock %}
I have my index page with this code with jinja:

{% block content %}
<div class="gtco-section border-bottom">
        <div class="gtco-container">
            <div class="row">
                <div class="col-md-8 col-md-offset-2 text-center gtco-heading">
                    <h2>Artigos</h2>
                    <p>DescriΓ§Γ£o sobre seus artigos.</p>
                </div>
      </div>
      {% for post in posts %}
            <div class="row">
                <div class="col-lg-4 col-md-4 col-sm-6">
                    <a href="images/img_2.jpg" class="fh5co-project-item image-popup">
                        <figure>
                            <div class="overlay"><i class="ti-plus"></i></div>
                            <img src="images/img_2.jpg" alt="Image" class="img-responsive">
                        </figure>
                        <div class="fh5co-text">
              <h2>{{ post['title'] }}</h2>
              <p>by {{ post['username'] }} on {{ post['created'].strftime('%Y-%m-%d')}} </p>
            </div>
            
            {% if g.user['id'] == post['author_id'] %}
              <a class="action" href="{{ url_for('blog.update', id=post['id']) }}">Edit</a>
            {% endif %}
          </a>
        </div>
        {% if not loop.last%}
          <hr>
        {% endif %}

      {% endfor %}     
        </div>
    </div>
</div>
{% endblock %}

And when i run, i get this erro:
jinja2.exceptions.TemplateAssertionError: block 'content' defined twice

#

When i use: {% block page_content%} {%endblock %}, work but the style looks...

#

Anyone please can help me?

#

mark me if answer

raven harbor
#

Iv completed my template and now I don't know where to start , I need to make a login using database . Can anyone help me with a link or an example file please that will mean the world to me

meager anchor
#

which web framework are you using?

raven harbor
#

Django

meager anchor
#

use the built-in authentication system

raven harbor
#

Can I use sqlite in django to run a shopping site ?

#

To access my login page I wanna create a new python file as login.py to code them into database?

meager anchor
#

sqlite and django are just tools to get something done, your question is like β€œcan i use fork and knife to eat salad”

#

yes, you can, and your second question is incomprehensible

raven harbor
#

How can I make login process done . Now I just have html file ,how can I link python to it . It may be hard to explain. Can u send link to any video or a blog where I can learn

#

I searched many I can't find the apt one

patent aspen
#

So im pretty new to this and i was just wondering what people mean by add this file to your "working directory"

meager anchor
#

working directory usually means the folder you're currently in

#

like the folder you run code from and whatnot

#

In computing, the working directory of a process is a directory of a hierarchical file system, if any, dynamically associated with each process. It is sometimes called the current working directory (CWD), e.g. the BSD getcwd(3) function, or just current directory. When the pr...

cobalt moat
#

How do i start or where

#

with python web dev

stone pelican
#

2 popular libs for website development are Flask and Django (although there are others, such as sanic and vibora)

#

I would suggest looking at Corey Schaefer's tutorials on YouTube about Flask and Django

#

This is assuming you have a moderate knowledge of python already

cobalt moat
#

Thank you.

grand badge
#

I think we need to pin an explanation of the differences of flask and django in this channel because it keeps getting asked

little nexus
raven harbor
#

@native tide need ur help

grand badge
#

ask your question

#

@raven harbor

raven harbor
#

Sure . how hard is it to make payment page in website

#

I'm just started python

grand badge
#

if you just started with python i suggest you learn the basics of the language first before you move onto web development @raven harbor

#

!t resources

lavish prismBOT
#
resources

It can be difficult to know where to begin when you are first starting out with Python. On our website, we have compiled a list of both free and paid resources that we recommend for learning and mastering Python.

It is hard to say exactly where you should start, as everyone will have a different prefered method of learning, but whether you like video tutorials, books or courses, you should find a suitable resource on our resources page

elfin trench
#

why wont my CSS image load? im using flask btw

#

the image is in my static folder too

#
@import url("https://fonts.googleapis.com/css?family=Roboto");

body {
    background: url("{{url_for('static', filename='/imgs/background.png')}}");
    margin: 0;
    font-family: "Roboto", sans-serif;
}

.navbar {
    display: flex;
    justify-content: center;
    align-items: center;
    position: fixed;
    width: 100%;
}

.navbar div {
    display: inline-block;
    margin: 27px 0 0;
}

.navbar div:not(:last-child) {
    margin-right: 30px;
}

.navbar div a {
    text-transform: uppercase;
    font-weight: bold;
    color: rgba(0, 0, 0, 0.7);
    padding: 12px;
    text-decoration: none;
    font-size: 15px;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.3);
    background: #fff;
    border-radius: 5px;
    transition: all 0.25s ease;
}

.navbar div a:hover {
    color: rgba(0, 0, 0, 0.4);
    transition: all 0.25s ease;
}

.navbar div .active {
    color: #000;
}

#splash {
    min-height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
}

#profile {
    box-shadow: 0 0 50px rgba(0, 0, 0, 0.3);
}

#profile, #title {
    display: inline-block;
}

#profile {
    width: 200px;
    border-radius: 50%;
    margin-right: 15px;
}

#title {
    margin-left: 15px;
    color: #fff;
}

#title h4 {
    font-weight: 100;
    color: rgba(255, 255, 255, 0.7);
}

#title h1, #title h4 {
    margin: 0;
}
#

^ is my css code too

native tide
#

url("{{url_for('static', filename='/imgs/background.png')}}");

#

i dont think jinja2 works in .css files

elfin trench
#

oh

#

then what do i do

native tide
#

just use the path

#

of the image

elfin trench
#

i've tried that

#

hasnt worked either

#

ill try again

native tide
#

how are you rendering the css

#

on html

#

in your html page

elfin trench
#

background: url("../imgs/background.png");

#

is that fine?

native tide
#

<link rel="stylesheet" type="text/css" href="../static/nav.css">

#

yea

#

and make sure this is in your html

elfin trench
#

huh now it works

native tide
#

and rename the css file to whever it is

elfin trench
#
<html>
  <head>
    <title>SoulSen - A Developer</title>
    <link rel="stylesheet" href="{{url_for('static', filename='assets/css/indexstylesheet.css')}}"/>
  </head>
  <body>
    <div class="navbar">
      <div><a class="active" href="#">Home</a></div>
      <div><a href="//somewhere">Minecraft</a></div>
      <div><a href="//somewhere">Applications</a></div>
      <div><a href="//somewhere">Login</a></div>
    </div>
    <div id="splash">
      <img id="profile" src="https://i.imgur.com/JjcWXJF.gif">
      <div id="title">
        <h4>Hello, I am</h4>
        <h1>SoulSenGaming</h1>
      </div>
    </div>
    <script src="{{url_for('static', filename='assets/js/scripts.js')}}"></script>
  </body>
</html>
#

thats my html

#
from flask import *
app = Flask(__name__)

username = 'This Is A Person'

@app.route('/')
def index():
    return render_template('pages/index.html')

if __name__ == '__main__':
    app.run(debug=False)
#

__init__.py

native tide
#

ok

elfin trench
#

all good?

native tide
#

yea if that is indeed the file location

#

and it's working

elfin trench
#

yep it is

#

ty

native tide
#

np

#

Ok now I have a question for someone if they could help me out?

#

I'm helping a college prof out by creating some web application for him. It's something to do with electrical engineering, but just wants to record data. He has given me these requirements:

At the home page, there is one form, a text field and a submit button. This form creates a new page and uses what was in the text box as the title.

The navigation bar updates with the page that was created (THIS IS DONE)

On the pages that are created, there is one form that has a dynamic number of fields. This is where it gets tricky for me. He wants to start out with one empty text field and a button that says "Add Note". So when you click this button, it adds a new empty text field. The page also has a second button that is for saving the notes. (THIS IS DONE)

What I don't know how to handle is the generation of new pages. I can certainly add text to a navbar when a form is submitted, but not sure how to keep generate a new page and then view it dynamically. One thought was to literally create a new file page1.html and add in html and jinja2 code in a method somewhere. I can easily create a file and add some text do it, but didn't know if I'm overthinking this?

elfin trench
#

also one more thing i know this isnt a CSS discord but how would i make something happen on click of a image?

digital bluff
#

that's not really css

elfin trench
#

well ok js

#

xD

#

but how would i do it

knotty lark
#

You'd need to look into dom events

#

If the result you want from the click is a change in CSS you can perform that change from the script by either adding styles to the element or adding a class

elfin trench
#

cause i want to just go back to the previous page

#

but idk how i would get that

knotty lark
#

Oh.

#

Well you can simply wrap your element in an <a href="blah"></a> tag no?

elfin trench
#

but how would i get the previous page?

#

cause it could be multiple

knotty lark
#

oh okay

elfin trench
#

well for my website