#web-development

2 messages ยท Page 67 of 1

native tide
#

;p

#

my browser is just prepetually loading

#

and timed out

#

hmm

#

uwsgi console said nothing,too

#

port 5000 is open, and i bound to 0.0.0.0

#

Can i use jinja syntax without importing django or flask

native root
#

Try curl'ing it from the lcoal machine

#

I'd have expected that to work but you could have iptables or smth

native tide
#

local machine being my vps :S

#

it worked on from my vps

#

Can i use jinja syntax without importing django or flask
@native tide ye

#

oh

#

jinja2 library has a render method somewhere

#

so it responded

#

to itself

#

like i have a list and i want to display it in my html files one by one

#

ye you can

#

but what should i do in my python in order to do that

#

cuz the list is in my py file

#

there's examples on that page ^^

native root
#

So that probably means you've got a firewall, no biggie

native tide
#

as long as your jinja is set up to loop thru the list

#

and ye probs

native root
#

but, with that, we can confirm that you can run a flask app

#

now, try it exactly the same but with your normal app instead

native tide
#

hm

#

ok

#

its freaking out about not finding config -.-

#

wait i might knw why

#

:o

native root
#

You figure it out?

native tide
#

yep

#

i um

#

did a stupid

native root
#

lol

native tide
#

ok so.. i just need to link it with apache now

#

right?

native root
#

yep

#

in your apache config you ought to have a mod_wsgi/ WSGIScriptAlias directive?

native tide
#

this is in sites-enabled

#

and is enabled

#

wait

#

ok so

#

WSGIScriptAlias / /home/crazygmr101/ansura/website/ansurasite.wsgi

#

i now know it's probs this line

native root
#

yes

native tide
#

welp. that 404's too =/

native root
#

Check your apache log file

native tide
#

uh

#

how

native root
#

probably

#

/var/log/apache

#

in there

#

error.log or similar

native tide
#

oh. yea.

#

im.. dum

#

xD

#

Anyone here used the Pyramid framework? How did you like it?

#

error.log shows nothing

#

nothing recent anyway

#

access.log shows a bunch of 404's

native root
#

hm

native tide
#

it's currently 4:51 on the server

native root
#

well,

native tide
#

why isnt my own 404 age coming up O.o

#

like, it's not even loading that

native root
#

odd

native tide
#

but yet it knows enough about the / route to load all the resources

native root
#

There's probably a wsig error page

#

but also, here's the example config:

#
<VirtualHost *:80>

    ServerName www.example.com
    ServerAlias example.com
    ServerAdmin webmaster@example.com

    DocumentRoot /usr/local/www/documents

    <Directory /usr/local/www/documents>
    <IfVersion < 2.4>
        Order allow,deny
        Allow from all
    </IfVersion>
    <IfVersion >= 2.4>
        Require all granted
    </IfVersion>
    </Directory>

    WSGIScriptAlias /myapp /usr/local/www/wsgi-scripts/myapp.wsgi

    <Directory /usr/local/www/wsgi-scripts>
    <IfVersion < 2.4>
        Order allow,deny
        Allow from all
    </IfVersion>
    <IfVersion >= 2.4>
        Require all granted
    </IfVersion>
    </Directory>

</VirtualHost>
#

which is significantly differnt than yours

native tide
#

well their docroot is different, and their app is in a diff place

native root
#

Or for separate process:

#
<VirtualHost *:80>

    ServerName www.example.com
    ServerAlias example.com
    ServerAdmin webmaster@example.com

    DocumentRoot /usr/local/www/documents

    Alias /robots.txt /usr/local/www/documents/robots.txt
    Alias /favicon.ico /usr/local/www/documents/favicon.ico

    Alias /media/ /usr/local/www/documents/media/

    <Directory /usr/local/www/documents>
    <IfVersion < 2.4>
        Order allow,deny
        Allow from all
    </IfVersion>
    <IfVersion >= 2.4>
        Require all granted
    </IfVersion>
    </Directory>

    WSGIDaemonProcess example.com processes=2 threads=15 display-name=%{GROUP}
    WSGIProcessGroup example.com

    WSGIScriptAlias / /usr/local/www/wsgi-scripts/myapp.wsgi

    <Directory /usr/local/www/wsgi-scripts>
    <IfVersion < 2.4>
        Order allow,deny
        Allow from all
    </IfVersion>
    <IfVersion >= 2.4>
        Require all granted
    </IfVersion>
    </Directory>

</VirtualHost>
native tide
#

i dont need the ifversion cuz ik i have above 2.4

#
<VirtualHost *:80>

        ServerAdmin webmaster@localhost

        ServerName ansura.xyz
        ServerAlias www.ansura.xyz

        WSGIDaemonProcess ansurasite user=crazygmr101 group=crazygmr101 threads=5
        WSGIScriptAlias / /home/crazygmr101/ansura/website/main.py


    <Directory /home/crazygmr101/ansura/website>
        WSGIProcessGroup ansurasite
        WSGIApplicationGroup %{GLOBAL}
        Require all granted
    </Directory>

        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined

RewriteEngine on
RewriteCond %{SERVER_NAME} =ansura.xyz [OR]
RewriteCond %{SERVER_NAME} =www.ansura.xyz
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
</VirtualHost>
#

hm

native root
#

I can see it's been starting btu I don't see wsgi starting, so are you sure the config is even running?

native tide
#

it.. should

#

how can i tell?

#

also

#

thats where i got my config from

native root
#

Put something invalid in it

native tide
#

ok

native root
#

crash is a personal favorite

native tide
#

apache errors

#

i just put akjhdashdaskjdhasdaskjdhkasdkhaskjdashjkdhashdasjdhasjdhsajd in it

native root
#

ok

#

hold on

#

unable to resolve host?

native tide
#

sudo has done that to me on every vps i've ever used

#

probs cux

#

cuz*

sand mason
native root
#

What's the apache error log say?

native tide
native root
#

ok, so it is loading

native tide
#

ye

native root
#

Is there an error log for wsgi itself somewhere

#

maybe /var/wsgi?

#

/var/apache/wsgi?

native tide
#

could check

#

according to the interwebs the best option is to set apache's log level to info

native root
#

Derp

#

I read over that three times

native tide
#

When using mod_wsgi, unless you or the web framework you are using takes specific action to catch exceptions and present the details in an alternate manner, the only place that details of uncaught exceptions will be recorded is in the Apache error log files. The Apache error log files are therefore your prime source of information when things go wrong.

native root
#

yeah do that ;-;

native tide
#

huh.

#

it started the process

#

o h

#

ok so

#

hm

#

how do i make it never ever look for a file and always use flask

#

or do i just change my docroot to the flask dir

native root
#

Try jsut removing the wrapping directory directive..

native tide
#

hm oki

#

but wait

#

thats not the dir it's erroring on

#

oh.

#

ok

#

so

#

i made /var/www/html/ansura/

#

if i remove the <directory> in site-available/ansura.conf

#

apache errors

native root
#

I wish I knew apache better

native tide
#

im just trying to figure out where it's referencing that dir

#

and i mean i bet you know a ton more than me oworoll

#

h u h

bleak bobcat
#

Ha.

native tide
#

what even is this

#

oh

#

wait

#

thats the default docroot

native root
#

lmao

native tide
#

hm.

bleak bobcat
#

Just change the ServerName and Alias in that section to localhost and you should be fine

native tide
#

it seems to be just ignoring wsgi

#

in both ssl and http?

bleak bobcat
#

In your last screenshot about apache conf

native tide
#

alr

bleak bobcat
#

The one pointing to /var/www

native tide
#

ye

bleak bobcat
#

It's just ignoring your other wsgi vhost file cause both are pointing to same domain

native root
#

It's autorewriting

bleak bobcat
#

Apache may need a DocumentRoot, iirc

native root
#

from http to https

#

then using your https to serve

#

and https has the documentroot

native tide
#

well thats my new https config

bleak bobcat
#

Oh right, I didn't even see the wsgi vhost is only on port 80

native tide
#

thats http

native root
#

You should put your old :80 on :443, and your :80 should just be the rewrite

native tide
#

so.. no http at all?

bleak bobcat
#

http only to redirect to https

native tide
#

oh

#

OH

#

okay

#

so.. do i keep the servername and alias in http?

bleak bobcat
#

Yea

native tide
#

alr

#

ah tmux is great

#

https on left, http on right

opal robin
#

hello i have a question realted to django

native tide
#

is this what i need?

opal robin
#

can someone help pleae

native tide
#

just ask.

native root
#

servernames on left are wrong

bleak bobcat
#

Change localhost back to your tld

native tide
#

s i g h

#

on both?

native root
#

yes

opal robin
#

how can i make a link inside of a page

#

of an app

#

on django

#

i have this

native tide
#

anything else?

opal robin
#

but it seems to give an error

#

sorry to interupt you

#

guys

bleak bobcat
#

Hmm I see the file on the left was generated by letsencrypt ?

native tide
#

ye

#

i'll remove the comments so you can see the whole thing

snow sierra
native tide
opal robin
#

@bleak bobcat please do you have some free time to help me

#

i would be very grateful

snow sierra
#

i want, only 1 header object.. and client must not have ADD HEADE function ...

opal robin
#

@snow sierra i'm facing some difficulties with slug too

#

may i ask you a question

snow sierra
#

of course... what about your question

native tide
opal robin
#

how can i make a link inside of a page
of an app
on django
path('string:slug/',views.article_detail)
i have this

bleak bobcat
#

Ah nice @native tide I was wondering where the instructions for the keyfile were

native root
#

Progress!

native tide
#

ok error logs it is

native root
opal robin
#

i'm not sure if this is the right way of doing it

native tide
#

it loaded the script :>

#

hmm

bleak bobcat
#

@opal robin Give your url a name, then in a template you do <a href="{% url 'your_url_name' %}">Click</a>

native tide
#

can i run flask in debug mode?

#

so i can see the entire stack trace?

native root
#

it should be showing up in error.log

#

from apache

native tide
#

its just one smol piece

#

and this flask app was just running

opal robin
#

@bleak bobcat i'm actually trying to do sth like this when i type localhost/parent/child i want it to show

#

so parent is the name of the app

native root
#

That's the whole error

#

it susing the wrong python

opal robin
#

than i want to make another link insinde views to point to child

native root
#

its pointed at python2 not python3

native tide
#

oh

#

ln -s /usr/bin/python /usr/bin/python3?

#

breaks entire system

native root
#

aaaa

native tide
#

so i need to point... what?

bleak bobcat
#

noooo

native tide
#

xxDD

#

im not that dumb

bleak bobcat
#

^^

#

Do you use a venv ?

native tide
#

so what am i pointing?

#

and uh

#

no

#

the vps is for discord bots so like

#

they all use the same packages anyway

native root
#

See WSGIPythonHome

native tide
#

alr

#

wait

#

in apache?

native root
#

yes

bleak bobcat
#

In WSGIDaemonProcess directive

snow sierra
#

how do i disable ADD HEADER+ function? i want only 1 object in ... if there is 1 object (turn off add function) just how?

native tide
#

oop

#

nope

#

apache does not like that

bleak bobcat
#

Hmm, question, do you have libapache2-mod-wsgi-py3 or libapache2-mod-wsgi installed ? ๐Ÿ™‚

native tide
#

oh

#

hm

native root
#

hm

bleak bobcat
#

(assuming debian based)

native tide
#

ye

#

ubuntu 18.04

#

heh..yea..i have py2 version.

#

lemme swap rq

bleak bobcat
#

It should use the right python without you needing to specify it then

native tide
bleak bobcat
#

its ok, install the py3 one now

native tide
#

oh

#

i restarted

#

and it's hanging

#

thats new

#

ok now it's missing packages

#

wait

#

excuse me

#

am confused

native tide
#

this - i'm so close

#

it's trying

#

):

#

ohh

#

can i just symlink python3 to python3.7

#

cuz thats why

bleak bobcat
#

use pip3, not pip

native tide
#

i used pip thru python3.7

bleak bobcat
#

Is that why ? Isn't python3 already linking to python3.7 ?

native tide
#

3.6 i think

bleak bobcat
#

Ah

#

Don't do it by hand

native tide
#

update-alternatives?

bleak bobcat
#

Yup

native tide
#

but

bleak bobcat
#

add python3 at the end

native tide
#

ah

#

no alternatives

bleak bobcat
#

update-alternatives --install /usr/bin/python3 python /usr/bin/python3.7 2

native tide
#

use pip3, not pip
but yea i always use python3.7 and python3.7 -m pip directly

#

o alr

bleak bobcat
#

hmm

#

Second python might need to be python3 too

native tide
#

ah

#

does it?

bleak bobcat
#

Yea use python3 instead of just python for the second one

native tide
#

well i kinda cant now

#

vut

#

but*

bleak bobcat
#

Oh right

native tide
#

seems to have done the trick

#

um

#

yea

bleak bobcat
#

yea...My bad, command I gave you was for adding python3 as an alternative to python....

native tide
#

wait

#

but

#

if i use python and python2.7

#

i can fix it

#

right

bleak bobcat
#

update-alternatives --remove python /usr/bin/python3 and update-alternatives --remove python /usr/bin/python3.7

native tide
#

o

#

ok

#

and the command i just sent?

#

that'll get py2 working right

#

update-alternatives --install /usr/bin/python python /usr/bin/python2.7 2

#

then
update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.7 2

#

?

bleak bobcat
#

yea

native tide
#

oki

#

ok now to restart apache

#

hm

bleak bobcat
#

That just installed those as alternatives, check that the bin is actually using them ^^

native tide
#

im stillgetting the dotenv errors tho

distant trout
#

@native tide got it, thank you!!

bleak bobcat
#

Meh...

#

You sure you don't wanna use a venv ? x)

native tide
#

i mean ig i can but like

#

why is it happening with flask all of a sudden

#

i've always just used globals

bleak bobcat
#

I don't know :/ I'm mostly a uwsgi + django guy

native tide
#

well.. can i move this to a venv without changing the dir it's in?

#

or is that not a thing

bleak bobcat
#

You can but you'll need to specify your venv path in apache

native tide
#

wh

#

hm

bleak bobcat
#

I'll be available to help more if you want in a few hours, gotta work rn ๐Ÿ˜ฆ

native tide
#

ah

#

oki

#

well ask me if i figure it out in a few hours then ;p

#

hf at work

#

it's still using py3.6 ):

native tide
#

why am i getting an error

#

can't you use operators in jinja2?

#
Hello {{name}}!
i like your lastname "{{last_name}}"

you enter a bar...
{%if {{age}} > 18 %}
You are old enough to enter the bar ({{age}})>
{%elif {{age}} < 0%}
You are not even born yet. Scram!!
{%else%}
You are not old enough ({{age}})
{%endif%}

Now i shall display your pets
{%if len(pets) == 0%}
You have no pets
{%elif len(pets) <=2%}
You didn't enter three or more pets so I ain't displaying anything</p>
{%else%}


{%for i in pets.split() %}
i
{%endfor%}

{%endif%}```
#
  File "app.py", line 6, in <module>
    template = env.get_template('mad_libs.txt')
  File "C:\Users\Angelo Hoft\.virtualenvs\jinja_example-CHyGP6N2\lib\site-packages\jinja2\environment.py", line 883, in get_template
    return self._load_template(name, self.make_globals(globals))
  File "C:\Users\Angelo Hoft\.virtualenvs\jinja_example-CHyGP6N2\lib\site-packages\jinja2\environment.py", line 857, in _load_template
    template = self.loader.load(self, name, globals)
  File "C:\Users\Angelo Hoft\.virtualenvs\jinja_example-CHyGP6N2\lib\site-packages\jinja2\loaders.py", line 127, in load
    code = environment.compile(source, name, filename)
  File "C:\Users\Angelo Hoft\.virtualenvs\jinja_example-CHyGP6N2\lib\site-packages\jinja2\environment.py", line 638, in compile
    self.handle_exception(source=source_hint)
  File "C:\Users\Angelo Hoft\.virtualenvs\jinja_example-CHyGP6N2\lib\site-packages\jinja2\environment.py", line 832, in handle_exception
    reraise(*rewrite_traceback_stack(source=source))
  File "C:\Users\Angelo Hoft\.virtualenvs\jinja_example-CHyGP6N2\lib\site-packages\jinja2\_compat.py", line 28, in reraise
    raise value.with_traceback(tb)
  File "templates\mad_libs.txt", line 5, in template
    {%if {{age}} > 18 %}
jinja2.exceptions.TemplateSyntaxError: expected token ':', got '}'
bleak bobcat
#

Remove the {{ }} around your variables when you're already inside a {% %}

native tide
#

:D

#

@bleak bobcat @native root ty both!!!! owohappyfwog

#

also my error pages are da best :3

#

what was the problem?

#

every. single. thing.

#

hahah

#

:D

#

did you create an env after all?

#

no

#

i just ended up installing the packages in py3.6

#

lmao, I see..anyway, the effort paid off (I think)

#

well

#

i just need to debug a few things

#

but yes

#

:>

#

hf then ๐Ÿ˜„

#

yea just python complaining about a key that should be there

#

but i mean idek why i'm using an .env for my token

#

the repo is private

native tide
#

so you can't use the len function in jinja?

bleak bobcat
#

Yes and no. You can't use it like you'd use it in python, you gotta use a filter :
{% some_var|length > 0 %}

coral raven
#

Hey

#

Can anyone suggest me some sublime packages for html, css and java

#

There are a lot and I cannot choose

bleak bobcat
#

Don't know much about sublime but emmet is a must have for me on any editor/IDE

coral raven
#

I have that

#

I need a autocomplete package

bleak bobcat
#

Then I can't really help more, I haven't used sublime for a few years

covert trench
#

Can I use flask_mysqldb without route, in normal function?

#

bcs I getting error in normal function, without route connection is None

vague bison
#

Hi, I've finished a tutorial yesterday about making a blog-like website in Flask+Python with SQLite3, but now I want to improve and start using PostgreSQL. But I can't find anything that could help me from the beginning. I think I would just need to modify this part of the code where I declare what db I use and connecting?

app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///posts.db'
db = SQLAlchemy(app)

db = SQLAlchemy(app) ```
glass sandal
#

app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///posts.db' needs to be app.config['SQLALCHEMY_DATABASE_URI'] = 'postgresql://user:password@host:port

#

Other things are okay

#

(host and port would be like 127.0.0.1:1234 based on your database settings in case you didn't know)

#

Btw you need to install some libraries

#

Like psycopg2

finite heron
#

Hello... I have a dash web app i'd like to deploy in my network via my own windows servers. Can anyone source me some good resources on how to do such thing? Thanks in advance.

native tide
#

@native tide you can't use operators in flask

#

How do i use the zip function in jinja2?

#

idk

#

i learned yesterday you cant use operators

#

bs imo

#

๐Ÿ˜ซ

#

you can do other things

dense slate
#

If I am listing all future events like so:
future_events = all_events.filter(start_time__gte=today).order_by('start_time')
Is there a way to also include dates that do not have a date set? I don't want past dates, but I do want to include "open" events where dates have not been selected.

molten quarry
#

When approaching a new site, what order would you guys recommend starting from? (Idea, Backend, frontend, design, desired features...). I'm looking into making my first site (touch-typing practice site) and am thinking that the best approach would be to start with the design/features so that I know what I'll need to code.

dusk spade
#

good idea

#

get some organization first before you start banging away at the keyboard like a maniac so you don't waste time zoop

fallow warren
#

so im using a gradient for my background with 3 colors

#

but for some reason when i resize the screen the background breaks into seperate colors

#

how can i fix this in css

#

?

quick cargo
#

how are you making the gradient

#

just lineargradient?

fallow warren
#

no

quick cargo
#

how r u doing it then?

fallow warren
#

nvm i am

#
body {
    background-image: linear-gradient(to bottom, rgba(225, 125, 57, 0.57), rgba(255, 131, 59, 0.95), rgba(255, 212, 0, 0.67));
    background-position: center;
    background-repeat: repeat;
    background-size: cover;    
    padding: 0;
    margin: 0;
}
quick cargo
#

you shouldnt need those backgroud pos, repeat and size bits

#

but you might need to set the height and width to screen size

fallow warren
#

but it breaks

#

if u resize the screen

#

i dont think taking those out wud do anything

quick cargo
#

hmmm

fallow warren
#

like the color seperates

#

and doesnt 'blend' anymore

quick cargo
#

if you quickly copy:
background: linear-gradient(150deg, #E1542A 15%, #9900FF 100%); and use that

#

and resize

#

does it still do the same thing

fallow warren
#

ya

#

r u using vscode?

quick cargo
#

i use pycharm

native tide
#

how can i use python operators in flask

#

example

#
{% if guild['permissions'] and 0x20 == 0x20 %}
#

That's Jinja2

#

or instead of and you can use &

#

oh

#

still though

#

what's this 0x20 == 0x20 and what's your question specifically? what operator do you want to use

#

and or &

#

and i get an error jinja2.exceptions.TemplateSyntaxError: expected token 'end of statement block', got 'x20'

#

that

#

i know the code works in python

#

but jinjas lack of operators

#

and and or are correct in Jinja2

#

no

#

do you have an {% endif %} block ?

#

yes ofc

#

run this in your cmd prompt:

#
if 104189504 and 0x20 == 0x20:
    print("yess")
else:
    print("nooo")
#

then run it in jinja

#

why would I do that?

#

im just trying to prove to you its a jinja issue

#

and and or are correct in Jinja2
@native tide ^^^this is false

#

thats the link ^

#

of what im trying to do basically

#

Go on their docs then

#

and read it for yourself

#

dude

#

what the fuck did you think i did

#
(permissions & 0x40) == 0x40   # True
(permissions & 0x800) == 0x800 # True
#

`

#

you dont think i read there docs

#
For if statements, for filtering, and if expressions, it can be useful to combine multiple expressions:

and
Return true if the left and the right operand are true.

or
Return true if the left or the right operand are true.
#

i already know

#

I m done helping here, have a good one

#

this is false bud

#

you can literally test it for yourself

#

0x20 == 0x20 stupid and it doesn't work like that in jinja2. Is that a hex?

#
Permissions are stored within a 53-bit integer and are calculated using bitwise operations. The total permissions integer can be determined by ORing together each individual value, and flags can be checked using AND operations.
#

or bits

#

bits

#

0x20 == manage_guild permission via discord

#

MANAGE_GUILD * 0x00000020 Allows management and editing of the guild

#

an example is

#

are you referring to the bitwise operators and not logical ones?

#

when you said

#

and and or

#

logic ones

#

then what I sent you is correct

#

try this example print(104189504 and 0x20 == 0x20) in python env and jinja

#

no, its not

#

literally try it for yourself

#

I get true

#

,which is expected

#

yes

#

now run

#
{% if 104189504 and 0x20 == 0x20 %}
#

in jinja

#

you will get jinja2.exceptions.TemplateSyntaxError: expected token 'end of statement block', got 'x20'

#

because jinja thinks x20 is a variable name

#

try

#

0x20|int() == 0x20|int()

#

can you includ this 104189504

#

in what you told me to try

#

{% if 104189504 and 0x20|int() == 0x20|int()%}

#

same error

#

it doesn't render bits the way you think

#

why don't you do that check in python

#

and you do it in jinja

#

do you really need it there?

#

yes, i do

#

{% if 104189504 and 0x20|string() == 0x20|string()%}

#

okay

#

actually

#

same error

#

give me the traceback

#

and the whole if statement block

#
{% for guild in guilds %}
        {% if 104189504 and 0x20|string() == 0x20|string() %}
            <h2 class="trans_hovr" style="color: white;"><img alt="" style="height: 3.5%; width: 3.5%; border-radius: 50%; border: solid white; margin-right: 1%; filter: drop-shadow(-5px 5px 10px black); transition: " src="https://cdn.discordapp.com/icons/{{ guild['id'] }}/{{ guild['icon'] }}"/>{{ guild["name"] }}</h2>
        {% endfor %}        
    {% endfor %}
#

you end for

#

twice

#

fuck

#

instead of string

#

put

#

{% if 104189504 and 0x20|int(base=2) == 0x20|int(base=2)%}

#

from when you asked

#

Update the code as I told you

#

yep

#

works?

#

no

#

same error

#

jinja2.exceptions.TemplateSyntaxError: expected token 'end of statement block', got 'x20'

#

send me the block again

#
{% for guild in guilds %}
        {% if 104189504 and 0x20|int(base=2) == 0x20|int(base=2) %}
            <h2 class="trans_hovr" style="color: white;"><img alt="" style="height: 3.5%; width: 3.5%; border-radius: 50%; border: solid white; margin-right: 1%; filter: drop-shadow(-5px 5px 10px black); transition: " src="https://cdn.discordapp.com/icons/{{ guild['id'] }}/{{ guild['icon'] }}"/>{{ guild["name"] }}</h2>
        {% endif %}        
    {% endfor %}
#

ok

#

try

#

{% if 104189504 and '0x20'|int(base=2) == '0x20'|int(base=2)%}

#

ok

#

looks like its working

#

ok

#

hm

#

check further for yourself

#

thanks

#

@native tide actually

#

i dont think it works

#

as it shows all my guilds

#

because that condition you sent me is true all the time

#

exactly

#

it shouldnt be always true

#

then modify it

#

not possible

#

if i wanted a statemnet that was always true i wouldve done something 1000000000000000000x easier

fallow warren
#

whhenever i resize my screen

#

the footer breaks

#

is there any way to fix that>

#

?

vivid rose
#

Anyone have a good method for creating dynamic fields in flask? I'm able to use fieldlist to generate additional fields but I'd like to add a button so that users can add and remove fields like in this gif.

hollow lintel
eternal frigate
#

Thats the code for forbidden requests?

#

It is. Probably the site employs bot detection mechanisms

#

Use browser's network monitor to see the requests the site makes to the server when it is loaded

#

I think it is not allowed to talk about it in this server

#

!rule 5

lavish prismBOT
#

5. Do not provide or request help on projects that may break laws, breach terms of services, be considered malicious/inappropriate or be for graded coursework/exams.

icy wasp
#

I posted this in #databases and have had crickets, so trying here.
https://www.youtube.com/watch?v=CSHx6eCkmv0
I am learning Flask by following Corey Schafer's Flask Tutorial and am having trouble writing the newly 'registered users' to my sqlitedb. The SQLite DB file is created, I can register a user, and no traceback error appears. specifically, my error varies from the video tutorial when registered user is not appearing in the DB like in 9:58. instead, I receive a None value.

the question: why isn't the newly registered user not appearing in the SQLite db?

In this Python Flask Tutorial, we will be learning how to add users to our database. We will then create an authentication system so that users can log in and log out of our application. We will be using the flask-bcrypt and flask-login extensions to help us with this. Let's g...

โ–ถ Play video
vivid rose
#

@icy wasp you'll need to provide some kind of code to get help. Put it on pastebin or something and link here.

icy wasp
#

@vivid rose ok. Will do. Give me a sec.

native tide
#

I am good at flask, django.

icy wasp
#

@native tide great. Your website looks very well done. Could you provide some guidance on my code?

vivid rose
#

@icy wasp sorry, I was AFK for a bit. What IDE are you using?

icy wasp
#

funny you ask haha...I currently have python, IDLE, PyCharm, VS studio (just downloaded today), and VS code (just downloaded today); I am trying to decide which I should remove as I code in Python and now JavaScript. so I'll take anyone's input including yours haha

to answer your question, I run on PyCharm @vivid rose

vivid rose
#

@icy wasp I'm not to familiar with pycharm but in vscode you can use the debug tool. Set a breakpoint just before the DB commands (ideally right when you set the user_ variable) and then look through what all your variables are set as.

(You set a breakpoint by clicking to the left of the line number)

icy wasp
#

Can do same in PyCharm but havenโ€™t run my flask app - have only ran through the terminal. Thank you, nevertheless. Will do it tomorrow and update you. ๐Ÿ‘๐Ÿฟ @vivid rose

vivid rose
#

@icy wasp sounds good. If you want to see a good example of stuff working check out flask-base on GitHub. They have user managment and everything. I based my first project of of it.
https://github.com/SelfhostedPro/Yacht

stiff totem
#

Hey guys, my django app's self.request.user become Anonymous after redirected from another domain.

#

is it possible to wait until session load?

#

LoginRequiredMixin can not detect user is authorized hence it became anonymous. i guess

fierce hare
#

Hey all. Im having trouble with the code below.

from sanic import Sanic
from sanic.response import json
from sanic.websocket import WebSocketCommonProtocol

app = Sanic("NoNameNotes WS")

app.config.WEBSOCKET_MAX_SIZE = 2 ** 20
app.config.WEBSOCKET_MAX_QUEUE = 32
app.config.WEBSOCKET_READ_LIMIT = 2 ** 16
app.config.WEBSOCKET_WRITE_LIMIT = 2 ** 16

@app.websocket('/feed')
async def feed(request, ws):
  while True:
    data = 'Hello!'
    print("Sending: "+data)
    await ws.send(data)
    data = await ws.recv()
    print("Got: "+data)

if __name__ == "__main__":
  app.run(host='0.0.0.0', port='25563', protocol=WebSocketCommonProtocol)

I get the error

Unhandled exception in event loop
Traceback (most recent call last):
  File "uvloop/handles/streamserver.pyx", line 143, in uvloop.loop.__uv_streamserver_on_listen
  File "uvloop/handles/streamserver.pyx", line 67, in uvloop.loop.UVStreamServer._on_listen
TypeError: __init__() got an unexpected keyword argument 'connections'```
#

And my /test route (on the frontend) code is this

<template>

  <section class="section is-large">

    {{ messageRxd }}

    <button @click.stop="getMessage">
      Test
    </button>

  </section>

</template>

<script>
export default {
  data() {
    return {
      messageRxd: ''
    }
  },
  mounted() {
    this.socket = this.$nuxtSocket({
      name: 'main',
      channel: '/feed',
      reconnection: false
    })
  },
  methods: {
    getMessage() {
      this.socket.emit('getMessage', { id: 'abc123' }, (resp) => {
        this.messageRxd = resp
      })
    }
  }
}
</script>

<style>

</style>```
minor horizon
#

Hello guys.
I have a basic back end. I'm simply using flask, gunicorn and ngrok. Say I got 1000 requests at the same time.
What should I do? It would be good if I could accept these requests one by one or let's say two by two, and keep the other requests wait.
What do I need to research? Which technology/tool? Thanks.

quick cargo
#

they pretty much work like that anyway

#

they just wait

#

Flask is sync so it litterally can only do one request at a time per process

minor horizon
#

Are you sure? I'm going to test this

quick cargo
#

providing the timeout doesnt expire normally yes

native tide
#

Is it possible to make web dashboard with websockets?

#

Or what should i use

rustic pebble
#

@native tide just http requests is fine

native tide
rustic pebble
#

Yes it is as well

native tide
#

How?

#

Oh like the html forms work

#

And if i use get then anybody can get the data

#

can someone help me to figure out where am i wrong, i am not able to figure it out lemon_sentimental

coral raven
#

What things should one know to become a stack developer

native tide
#

How can i send data from flask to discord.py
I mean post data to a python program thats not flask

unique hill
#

@rustic pebble are you good at python (specifically in using socketio)

tardy trellis
#

@coral raven Python, (html, css, javascript) or just bootstrap, flask to handle endpoints, jinja for templating, SQL.

#

I think i said most of the things to start with

#

@coral raven Or follow this dudes guide, its pretty helpfull

coral raven
#

@tardy trellis I know django,html and css

tardy trellis
#

@coral raven Then what do you need

coral raven
#

I need to know what else should I learn

#

Javascript

tardy trellis
#

I mean yeah javascript is a given

#

Its good to know it

coral raven
#

And sql too

tardy trellis
#

But you can still find pre made templates

#

So you dont have to start from scratch

coral raven
#

No

tardy trellis
#

Also SQL of course

quick cargo
#

SQL is meh

#

Most people starting wont touch it

coral raven
#

What is bootstrap

tardy trellis
#

CSS framework

quick cargo
#

and with django you never get close to it

#

technically its a CSS JS framework

tardy trellis
#

i mean its good to know it

coral raven
#

Sqlite

tardy trellis
#

An sql engine

quick cargo
#

Bootstrap is pretty old now

#

it still gets used but there are others out there

#

which dont cause issues if people dont have js enabled

tardy trellis
#

Its the same as Postgre and Mysql

#

Thats the one i tried first

#

and found it very easy

#

to start with

#

Bootstrap i mean

coral raven
#

I was reading online

#

And I saw node js pop up

#

Is it a web framework?

tardy trellis
#

Its a runtime environment

#

that runs javascript

#

express is a framework

#

but its has the same purpose like django

#

Its for the back end

rustic pebble
#

@unique hill I am proficient, havenโ€™t really used sockets for more than just simple chat

lucid portal
#

Hey guys, having a problem I'm hoping someone could help with?

native tide
#

How can i receive requests on a normal python program

lucid portal
#

New to discord (and to python) so hoping this is the right place to post

#

Trying to check a database to ensure a username does not already exist before allowing a user to register, but getting a runtime error for missing value for placeholder (:username). But I thought I was giving it a value? Here's the code:

  # Checks to see if username exists already, if so return apology
        usernamecheck = db.execute('SELECT EXISTS(SELECT * FROM users WHERE username=:uname)', uname=username)
        if not usernamecheck:
            return apology("Username already exists.")
mortal socket
#

how can i make a countdown using flask and redirects after the countdown ends

last abyss
#

Where i should ask django related question?

vestal hound
#

Where i should ask django related question?
@last abyss here

coral raven
#

What one text editor can I use with extensions for stack development

twilit zenith
#

you can use Sublime text or Visual Studio Code, these 2 are ones i personally use

mortal socket
#

how can i make a countdown using flask and redirects after the countdown ends
is this possible or i should use js for that

jagged lark
#

You probably need some very basic JS yeah

unique hill
#

@rustic pebble but can you help me

rustic pebble
#

No

#

I am not available atm

crisp saddle
#

For alembic migrations, are there anyone else in here who likes to write them in plain sql?
fx.

somehash_added_users.py
added_users/upgrade.sql
added_users/downgrade.sql

Where the added_users.py just have two functions, that calls something like this:

def execute(bind, filename: str):
    session = orm.Session(bind=bind)
    file_path = pathlib.Path(f"migrations/versions/{filename}").absolute()
    with open(file_path) as f:
        sql_to_execute = f.read()
        session.execute(sql_to_execute)
        session.commit()

However I have yet to automate it further ๐Ÿคทโ€โ™‚๏ธ

eager mural
#

Does anyone have suggestions for sanitising user input in pymysql? I'd also like to know how for aiomysql but my use for that isn't web related as such

bleak bobcat
#

I'd suggest using an orm

native tide
bleak bobcat
#

?

vague bison
#

Hi guys, I'm new. Could anyone help me where can I find beginner projects for python? I'm mainly want to use it for web. But all tutorials and pjocets I find is too complicated

bleak bobcat
#

Django's official documentation contains an easy to follow poll app tutorial

native tide
#

So

#

I want to communicate with my bot and my web application

#

so what I have so far is

#
import asyncio, datetime, random, websockets
import discord
from discord.ext import commands

TOKEN = ''

bot = commands.Bot(command_prefix=".", case_insensitive=True)
@bot.remove_command('help')

async def post_guilds(websocket, path):
    guilds = []
    for guild in bot.guilds:
        guilds.append(guild.name)
    await websocket.send(guilds)

@bot.event
async def on_ready():
    start_server = websockets.serve(post_guilds, "127.0.0.1", 5678)
    asyncio.get_event_loop().run_until_complete(start_server)
    asyncio.get_event_loop().close()



bot.run(TOKEN)```
#

but I get the error

#

event loop is already running

#

what does this mean and how do I fix it

#
<!DOCTYPE html>
<html>
    <head>
        <title>WebSocket demo</title>
        
    </head>
    <body>
        <script class="design">
            var ws = new WebSocket("ws://127.0.0.1:5678/"),
                messages = document.createElement('ul');
            ws.onmessage = function (event) {
                var messages = document.getElementsByTagName('ul')[0],
                    message = document.createElement('li'),
                    content = document.createTextNode(event.data);
                message.appendChild(content);
                messages.appendChild(message);
            };
            document.body.appendChild(messages);
        </script>
    </body>
</html>```
#

this is the html I use to preview it in the browser

crisp saddle
#

Isn't it kinda strange to use async but then go ahead and append the results to an array? @native tide

mortal socket
#

can i use psycopg2 without the Sqlalchemy

quick cargo
#

@native tide a few things

#
  1. Dont run a webserver and a bot in the same process
  2. run_until_complete is blocking because its intended to start the event loop, it will block the entire bot with or without an error
  3. dont close the event loop you will fuck your bot
#

@mortal socket Yes? Just use it like a normal SQL driver?

mortal socket
#

ok

quick cargo
#

also @native tide @bot.remove_command('help') isnt a thing that exists
you will just nuke that function bellow it

tardy trellis
#

@quick cargo Can you run 2 programs in the process ???

#

I though you could run only one

#

Or is it asynchronous

#

??

quick cargo
#

Well with what theyre trying todo no

#

you can run stuff with threading which can have two bits of blocking code running parallel but its not good to have a webserver and a discord bot running together

tardy trellis
#

@quick cargo So you think he should run them in different threads

#

??

quick cargo
#

He should run as seperate systems

tardy trellis
#

As different system processes ??

quick cargo
#

as in running them as two different programs

tardy trellis
#

Yeah thats what i said

#

Run them in different processes

#

One in PID 1 and the other in PID 2, for example

deep grail
#

Hey guys! I have a registration page. It has password confirmation as well. But the page doesnt actually check if passwords match

native tide
#

hey, is it possible to copy a 6 digit number from a website, like 123456 with selenium?

wind escarp
#

It should work

deep grail
#

I actually fixed it

#

had something wrong in my html file

wind escarp
#

Oh right

deep grail
#

Thanks for the concern regardless ๐Ÿ˜

wind escarp
#

No probs

native tide
#

yo

wind escarp
#

hey, is it possible to copy a 6 digit number from a website, like 123456 with selenium?
@native tide I used regex along side python requests module for that type of task but it wasn't 6 digit, it was a phone number

native tide
#

regex huh?

wind escarp
#

Regular expressions

#

Look This up "regex to find 6 digit numbers"

native tide
#

alright

#

thanks

wind escarp
#

No probs

distant trout
#

for front end

#

is it better to do mobile or desktop version first

bleak bobcat
#

mobile

distant trout
#

got it! thanks

amber plume
#

Hey, I got redirected to this channel from one of the help channels. This is my first question so I'll try to be as extensive as I can be, but if you need more information I'll do my best to give.
So, I'm a beginner learner, and have been following Programming with Mosh's video (/watch?v=_uQrJ0TkZlc). Toward the end of the course, he teaches us how to use the Django framework.
He recommends us to install Django 2.1, and we are working with Python 3. We have a project PyShop and an app for Products. We have set up the server and can log into the admin page. Up to this point I have double checked all the code and it is the same as shown in the video. I want to add a product to the table, but find myself with this error:
Exception Value: no such table: main.auth_user__old

I did a search online and found that either I downgrade SQLite or I update Django. I also tried doing the migrate step and runserver step again. (stackoverflow) Still same error message for me. Could anyone try helping me with this?

#

I suppose a fix could be that I rewrite all the code and start up the project again with the new version of Django, and would not take too long. but in the future, if this error were to come up again for a bigger project, it could be good to know if there is another solution

bleak bobcat
#

Why not update django ?

amber plume
#

I have updated it

#

same error

bleak bobcat
#

delete your database and try migrating again

amber plume
#

I assume the database is the .sqlite3 file?

bleak bobcat
#

Yup

amber plume
#

alright

#

oh brilliant, it works

bleak bobcat
#

๐Ÿ™‚

amber plume
#

Thank you ๐Ÿ™‚

bleak bobcat
#

no probleรน

#

fyi, when you're running django on production (live website instead of local) you shouldn't use the runserver (and probably shouldn't use sqlite either, but that's much less important)

amber plume
#

Alright. Not sure which direction I'm heading with my learning of Python, and this video course gives an introduction in a few areas. Maybe I'll choose web development since this stuff seems really useful and fun

mortal socket
#

there is anyway to host flask app w db on github pages

quick cargo
#

no

magic scarab
#

is there a way of adding nodejs to a flask app?

quick cargo
#

why would you mix a JS runtime with python exactly? @magic scarab

terse surge
#

prob hes running a discord js bot

#

and he needs some sort of communication between python and the bot

quick cargo
#

you wouldnt even do that tho

#

i dont get why people think having the webserver and bot on the same program is a good thing

terse surge
#

meant could not prob sry

#

yep same

magic scarab
#

no, i want to when i type in the search input for results to appear directly on the dropdown and not to redirect to a /search or idk

#

and the only way that comes to my mind is with react but i need the mongodb package

quick cargo
#

python has a mongodb package tho @magic scarab

echo ingot
#

hey guys, for my project i want to take data collected by the USGS, convert it into a heatmap, then update a preexisting heatmap on a website of mine. I'm using leaflet.js for my map, but i'm wondering if it's possible if i can update a map like that regularly?

autumn bobcat
#

How do I reverse a URL in django without knowing the app's namespace ahead of time?

coral raven
#

Hello guys!

#

I finished learning all the basics there is in python, created some projects

#

Not too difficult

#

What should I do now

#

All projects seem difficult to me

#

I want to get into web dev( I know HTML)

quasi ridge
#

so build a web site

coral raven
#

Just like that?

#

This is my first programming language

marble carbon
#

You can look into flask

marsh wadi
#

requests and beautifulsoup are some things to mess around with.

quasi ridge
#

yes, just like that. Spend a few hours with a tutorial and write "hello world" -- a site that has a single static page.

#

mess with that.

coral raven
#

So I should focus on flask, beautifulsoup, requests..
Rest all modules are not that umportant right?

quasi ridge
#

then maybe have a couple pages. Then maybe have some computed pages. Then have some state. Then try deploying the code to a Real Web Server Host. There's tons to learn,but you can edge into it all gradually.

#

I wouldn't think you'd need beautifulsoup unless your web site's purpose in life is to scrape other web sites.

marsh wadi
#

meh fun to mess around with. though yes, practically limited.

coral raven
#

What other skills/languages are required to get into web development

quasi ridge
#

bit of Unix sysadmin.

#

fair amount of HTML CSS JS

#

but don't wait to learn those; learn them as you go, messily.

#

at least that's what I did ๐Ÿ™‚

#

disclaimer: I am not a full-stack developer

marsh wadi
#

taking notes, how well did it go

coral raven
#

I studied html before everything and I think I should not have done that, could have done that with python definitely

quasi ridge
#

doesn't sound dangerous to me

molten quarry
#

If you're interested in Django web development, I highly recommend the book "Django 3 by Example". You get introduced to LOTS of Django techinques and related softwares (postgresql, celery, redis, memcached, uwsgi, nginx, channels, rabbitmq, etc). I'm on the last chapter, where it walks you through getting your project ready for production, and its been amazing. Learned how to do a bit of everything, and it'll be a great reference as I begin making my first website (Touch Typing practice)

#

You'll learn a big chunk of HTML just from following along, but I've also been dedicating a bit of time to a html/css book. Got a JS book (elequent JavaScript) that I'm also studying from which has rounded everything out.

coral raven
#

How much did you spend on between learning python basics to getting into django

molten quarry
#

I worked through 2 books (Python Crash Course and then Automate the Boring Stuff). However, if you've learned what classes are and how they work, the you're ready for Django.

crisp saddle
#

Or just go directly to endgame and skip django.

molten quarry
#

The book assumes you've at-least done the official beginners tutorial from the Django website.

crisp saddle
#

writhing monoliths in 2020. nathanYikes

molten quarry
#

If you're willing to dedicate a day, I highly recommend learning Dockers. Wish I would've started using them years ago. Life has been so much better, especially since I'm on windows and sometimes have trouble installing programs.

coral raven
#

Yes sir will do

pallid loom
#

i don't understand what's difference between django and django rest framework

#

could someone explain to me ?

last abyss
#

rest framework for api i think.

molten quarry
#

Yes, the rest framework is like a DLC for Django. Its a bunch of tools that make it easier to add an API (Used by things like mobile apps or external sites). However, it's not required to run a Django site.

severe folio
#

I like that a DLC for Django hahah

snow sierra
#

what you think guys, which is the easiest way to Translate pages in Django .,. i know i18n ,.. just looking for another way.

mortal socket
#
     {% if error %}
         {% import time as t %}
         <div class="alert alert-danger" role="alert" id="err">{{ error }}</div>
         {% endif %}
         {% t.sleep(3) %}
jinja2.exceptions.TemplateSyntaxError: Encountered unknown tag 't'. Jinja was looking for the following tags: 'endblock'. The innermost block that needs to be closed is 'block
#

help

snow sierra
#

i think last line is not correct... use {{ t.sleep(3) }}

#

and you have not endblock in template ... as error code said

ripe hemlock
#

Hello everybody, is it possible to post a photo on Instagram with Python?

rancid crane
#

With selenium yes

#

If Instagram allows user post images through website

restive kindle
#

Hi, I am using .matchAll on desktop and it works fine yet on mobile it says the function doesnt exist yet being confirmed to be supported on MDN. Is it a different function or something?

fickle fox
#

guys how instagram hides users images from web browser's inspector>

#

???

restive kindle
#

it doesnt

fickle fox
#

it does

#

there is no image tag

#

only div

restive kindle
#

It doesnt, look through the adjacent divs; it is there.

fickle fox
#

Nah not there

#

O nvm found it xD

terse surge
#

youre already in

#

since u have dev role...

warped falcon
#

In Django docs -- "
Metaย inheritance

When an abstract base class is created, Django makes anyย Metaย inner class you declared in the base class available as an attribute.ย 
"

What does that "available as an attribute. " mean?

ripe hemlock
#

your model._meta

#

the _meta will give you the data in the Meta class

warped falcon
#

@ripe hemlockhm, thanks.

native tide
#

Hey! How difficult is getting authentication working in Flask?

stray coral
#

using django-filter - how do I filter by selecting multiple values for example say I want to find blog posts by two authors

native tide
#

Also does anyone have the link to the django discord?

twilit zenith
#

@native tide it fairly easy, flask's Auth is easier imo

native tide
#

@twilit zenith Easier than djangos?

molten quarry
#

@stray coral python model_name.objects.filter(author__in=['author_1', 'author_2'])

stray coral
#

thank you

winter void
#
{% for tag in pagedata['tags'] -%}
{{ tag['name'] }}
({{ tag['number'] }})
{{ ", " if not loop.last }}
{%- endfor %}
#

I still get a whitespace

#

how do I get rid of this?

#

I'm trying to add tags to my bookmark app...
Oh yeah, and how should I do always have tag (number) on the same line?

#

maybe using a html span element with nowrap, i guess

twilit zenith
#

@native tide yeah Flask is much simpler, if you aren't building something big, I would suggest using flask instead of Django.

molten quarry
#

@winter void When you make a new line, HTML interprets that as a whitespace (not a full linebreak, just a space). Is that what you meant?

warped falcon
molten quarry
#

Sounds like it's telling you that you wont get a list of MyPerson objects directly. You'll always get a querysey object that contains MyPerson objects.

warped falcon
#

I didn't understand from the point "The whole point of proxy....."

native tide
#

Whats the simplest way to send data from flask to discord.py

vagrant dock
#

anyone one know a website were i can watch the walking dead for free

frail lark
#

Selenium keeps on having this problem when I try to run the chrome webdriver: ```SessionNotCreatedException('session not created: This version of ChromeDriver only supports Chrome version 81', None, None)

#

I have tried all the versions of the webdriver chrome has on their site, nothing

spice bough
#

@frail lark what version of Chrome are you driving?

frail lark
#

I've already fixed the problem

#

thanks for the offer, though!

spice bough
#

No problem @frail lark , what was the problem? Just a mismatch in versions?

frail lark
#

yeah, just needed to redownload an update

vagrant dock
#

@spice bough get what

spice bough
#

@vagrant dock the tv show you asked for

vagrant dock
#

@spice bough oh ok what u mean legal source i wanted it for free lol

spice bough
dull sable
#

Hello, I am having a problem regarding selenium. Is there anybody that can help?

spice bough
#

Iโ€™ve used selenium for a couple of things, what are you trying to do

dull sable
#

Lemme show ya

spice bough
#

Did you try selenium IDE and see how it chooses it?

dull sable
#

What does that mean?

spice bough
#

There's a noob version of Selenium that works as a browser extension

#

It can record your activity and turn it into a series of commands. From that you might discover how to access that button

dull sable
#

Thanks ill try it

spice bough
#

@dull sable let us know if it works

rigid laurel
#

@dull sable What you're trying to do both breaks rule-5 here (by breaking the google TOS), and is a giant pain in the ass compared to just using Google's translation API

dull sable
#

What is google's translation API

rigid laurel
dull sable
#

Literally the only thing left in my code is needing to press that button

rigid laurel
#

well - it breaks the Google TOS, so this server can't help you

#

!rule 5

lavish prismBOT
#

5. Do not provide or request help on projects that may break laws, breach terms of services, be considered malicious/inappropriate or be for graded coursework/exams.

dull sable
#

Oh sorry

#

I didnt know that broke a rule

spice bough
#

Does it actually break the TOS?

rigid laurel
#

you can't automate interaction with google

#

with google search that is

spice bough
#

I never would have thought xD

rigid laurel
#

they provide APIs for literally everything. There's really not much reason to want to scrape from them except cheapness

spice bough
#

That's fair

molten quarry
#

Finished my Django textbook and started my first site. Scary stuff not having someone hold my hand. Luckily I spent the last few days writing up a development roadmap, so I got an idea of what I should be doing first. Here we go!

crisp saddle
#

gl :-)

sonic ferry
#

Letโ€™s say user saves jpg at 75% quality, then uploads to your website which saves it at 75% quality. That user isnโ€™t gonna be pleased with the result?

frail ore
#

Hi guys, quick question. Im using flask to make an app and I have several buttons. Each button has its own form with the form action each sending to a different URL which I then create a route for and then execute code based on that (Ill attach SS). My question would be is that a "correct" or efficient way of doing it? Or would a better way to create one from, and each button sends a different value and then have 1 app route to listen and have an IF statement to differentiate between values

#

I dont know if that makes sense so ill send a SS of the codee

#

if you see what I mean i have a different route for each button, and as my app expands I will have many routes for every button, not sure if that is a weird/inefficient way of doing it

stray coral
#

Hi, I am using django-filters and want to paginate the filtered result, however, when I go to the next page , the filtering breaks and unfiltered data is displayed. Here is my code: https://dpaste.org/cZuC

sonic ferry
#

At Sam: I'm a noob, but, to avoid code duplication, I would go for a single route. Also, perhaps a dictionary could be used, instead of many if statements.

light needle
#

Made a REST API and want to validate a purchase and create virtual machines/containers with it. I have no clue on how to approach this. Someone got any tips?

native tide
#

Hey I want to make a really simple web framework for APIs. Where should I get started?

dull sable
#

"hallo", but so far i am not sure what is the right command

#

i tried getting the element ID and the doing element.text() but that returns the error message "unicode object is not callable"

stray coral
#

Hi, I am using django-filters and specifically DateFromToRangeFilter but it is not working. My code : https://dpaste.org/h2oZ

coral raven
#

Why is there filter.forms|crispy

azure rune
#

Which framework is better for an API endpoint, Flask or Django?

rustic pebble
#

@azure rune try using fastapi

quick cargo
#

Async frameworks will probably lend themselves to api's better because of the high throughput

topaz widget
#

Does anyone know if it's possible to inject code or strings to extract information a user shouldn't have access to into url query strings that are defined by changing script variables in the browser's console or by similar methods? User will not have a text form btw.

dense slate
#

Are there any trending websocket libraries now-a-days that would allow me use SSL and a back-end event loop?

#

I'm looking to connect players together randomly, in a tabletop RPG type session. 1 host and 4-5 players will connect together randomly to play a MUD-like game.

#

Have Django Channels gained any more traction?

quick cargo
#

Im not sure

#

I dont thing there is much support for it still because of how Django's worked itself

dense slate
#

Worked itself in what sense?

quick cargo
#

It lends itself very well for things like Ecommerce stuff and smaller sites that dont require as much low level control as larger systems

#

along with those sorts of sites dont necessarily have as much use of websockets especially with Django which is still currently not async safe

#

which is where micro async frameworks tend to go ahead of Django because theyre more performant in that end

native tide
#
@ app.route("/dashboard", methods=["POST", "GET"])
def dashboard():
    if "oauth2_token" in session:
        logged_in = True
    else:
        logged_in = False
    if request.method == "POST":
        ban_reason = request.form['ban_reason']
        sql = "INSERT INTO cb_718580065255948318 (ban_reason) VALUES (%s)"
        val = (f"{ban_reason}")
        cursor.execute(sql, val)
        db.commit()
        return redirect(url_for('dashboard'))
    else:
        return render_template("dashboard.html", logged_in=logged_in)

Error:

ReferenceError: weakly-referenced object no longer exists

any help will be nice ๐Ÿ™‚

#

nevermind, got it fixed

dense slate
#

along with those sorts of sites dont necessarily have as much use of websockets especially with Django which is still currently not async safe
@quick cargo

Interesting. I used Django with a websocket library that worked really well. I basically just used Django for the web server and ORM, and just made the loop in the websocket while the python back-end did all the work.

Worked really well except that the websocket wasn't SSL so I'm looking for an alternative.

frank nebula
#

Hello, im getting a problem using the requests library.

When i use requests.get(url), i just dont get any response...

If i use requests.get(url, timeout=5)
I get the response after 5 sec and etc...

It looks like the function just return anything after the timeout

#

I also reaslize that in simple html pages, this problem doesnt occur


r = requests.get('http://www.google.com', timeout=5)

[print(key, value) for key, value in r.__dict__.items() if key!='_content']

b = requests.get("http://www.brainjar.com/java/host/test.html", timeout=5)

print("\n\n\nSecond Request", b.elapsed)```

i get 

_content_consumed True
_next None
status_code 200
headers {'Date': 'Mon, 29 Jun 2020 22:49:08 GMT', 'Expires': '-1', 'Cache-Control': 'private, max-age=0', 'Content-Type': 'text/html; charset=ISO-8859-1', 'P3P': 'CP="This is not a P3P policy! See g.co/p3phelp for more info."', 'Content-Encoding': 'gzip', 'Server': 'gws', 'Content-Length': '5397', 'X-XSS-Protection': '0', 'X-Frame-Options': 'SAMEORIGIN', 'Set-Cookie': '1P_JAR=2020-06-29-22; expires=Wed, 29-Jul-2020 22:49:08 GMT; path=/; domain=.google.com; Secure, NID=204=D54suyp-J_USXnF-7VH7MZF6gIAybpdAZdaDyEPQIIMZ_qE-sP70T8p7uFhlfkFdzqzpPCUdtpQhXjH7EGjWTB6gxV7BxyGHMHfCVSWSZVTaas7iHHR3U5ulo48HLRIC_AoGBKxWNaqKyDf2s1sHFsjbkFCV23jEw1evPBgtYlo; expires=Tue, 29-Dec-2020 22:49:08 GMT; path=/; domain=.google.com; HttpOnly'}
raw <urllib3.response.HTTPResponse object at 0x7f1ad1cb80f0>
url http://www.google.com/
encoding ISO-8859-1

history []
reason OK
cookies <RequestsCookieJar[<Cookie 1P_JAR=2020-06-29-22 for .google.com/>, <Cookie NID=204=D54suyp-J_USXnF-7VH7MZF6gIAybpdAZdaDyEPQIIMZ_qE-sP70T8p7uFhlfkFdzqzpPCUdtpQhXjH7EGjWTB6gxV7BxyGHMHfCVSWSZVTaas7iHHR3U5ulo48HLRIC_AoGBKxWNaqKyDf2s1sHFsjbkFCV23jEw1evPBgtYlo for .google.com/>]>
elapsed 0:00:05.176726
request <PreparedRequest [GET]>
connection <requests.adapters.HTTPAdapter object at 0x7f1ad0e9c208>

Second Request 0:00:00.645876
[Finished in 15.6s]```

wild thunder
#

guys, anyone confortable with jquery that could give me a hand?

i want to make the following:

create table lines with data with an '+' button (& being able to delete it with a minus)
send the data from the tables to flask as a dict.

any tips?

icy wasp
#

@dull sable> i tried getting the element ID and the doing element.text() but that returns the error message "unicode object is not callable"
@dull sable did you encode the text to 'utf-8'?

#

Hello, im getting a problem using the requests library.

When i use requests.get(url), i just dont get any response...

If i use requests.get(url, timeout=5)
I get the response after 5 sec and etc...

It looks like the function just return anything after the timeout
@frank nebula the page could load with JavaScript I like to .get() with selenium.

frank nebula
#

@frank nebula the page could load with JavaScript I like to .get() with selenium.
@icy wasp problem kinda solved! Im forcing my requests to be IPV4 and now works normally

timid sphinx
#

its an input with a datepicker attached

icy wasp
#

@frank nebula awesome to hear. Didn't know that was a work around. Any idea what was the source of the problem?

timid sphinx
#

but (settablefilter) doesn't run unless you type, selecting a date from the picker doesnt update it

frank nebula
#

I installed Ubuntu recently and ithink it some socket problem. I know nothing about networks and sockets, so i cant tell where is the problem or how to solve

native tide
#

Anyone knows how to embed pagination with ajax in flask?

plain zealot
#

Hey guys, so first I hover over the image and it goes large which is fine. But as soon as the cursor leaves the image, the image enlarged which I donโ€™t want? Anyone know the reason why thanks

native tide
#

@shadow forum btw noticed your status, you shoud install the rich prescence plugin so if you dont want it to show "JetBrains IDE"

shadow forum
#

hmm

#

i probably should, ye

native tide
#

oop wrong channel

icy wasp
#

@frank nebula oh ok. gotcha. Good luck haha

native tide
#

is web development possible with just Html, Css, JavaScript and Django?

bleak bobcat
#

Yes

#

Technically web development is possible with only html...But that won't get you far

native tide
#

yes

#

html is ugly and i didn't spend enough time on my css skills

#

lol

thorny nexus
#

i need help with django

#

where can i learn django

#

any courses/tutorials?

bleak bobcat
#

Yea, official documentation has a poll app tutorial

thorny nexus
#

thx

restive marlin
#

Django has pretty complete docs on their website, I found this series helpful when I started out, though it is dated: https://www.youtube.com/watch?v=qgGIqRFvFFk&list=PL6gx4Cwl9DGBlmzzFcLgDhKTTfNLfX1IK

#

depending on the complexity of what you want to make, you might also like to look into something like flask; I find it requires less understanding upfront to be productive compared to Django

fair oriole
#

I'm looking at making a proper microservice, with either a REST API or event streams communications. For that I'll probably use some trivial libraries like Falcon or at most Flask.

However, since this is a proper production top knotch code, I need a resource to tell me what the best practices are, so that I don't reinvent the wheel.

So far everything I checked in any books about web development just briefly touch on this, with Hello World apps, and that's it.

How do I make it work with high demand? Where does asyncio best fit? How many gunicorn processes to start and why? What performance-related thoughts are also there? How do I write proper tests for it (what's the balance between feasibility and 100% code coverage)? How do I deploy it to the cloud properly? Which communication methods to use in which cases?

Did anyone encounter such a book, course, tutorial or anything? I know it probably won't be free, but this is really important for me.

restive marlin
#

@fair oriole The problem is that there is more than 1 best way for all of the questions you are asking and everything depends on everything. I also have not found any such resource that combines all these different subjects.

If deployments/performance questions are more of a means to an end I would recommend looking into serverless functions, maybe through a service like vercel) They have a fairly good deployment process baked into them and because of the serverless nature the scalability is really good. If you actually want to learn about all these things for the sake of learning, you will just have to read a bunch of resources and decide which you like the most I'm afraid.

As for application design and proper tests, I would seek out a place where you can get your code reviewed. the CS discord channel has a code-reviews section I believe. Many knowledgable people can and want to teach you how to improve your application, you just have to ask ๐Ÿ™‚

fair oriole
#

I was hoping for at least one interpretation of "best way" :)
But yeah, I saw serverless functions being used. The problem is that they get really expensive when you have sustained workloads, and in that case I'd be looking more towards Kubernetes.

I come from a data engineering background, and until now any python app needed to be clearly sequential. Whenever I need to do something in parallel I just create a swarm of threads that read from a task queue until an "end" message. This whole async thing has always eluded me, when I worked with JS, when it appeared in .NET, and now in Python. I know what it is and what it does, but I never got to properly work with it, and properly use it, and properly get book-quality explanation of why things are needed.

And now in an interview with a big company, I saw that user-event-driven back-end apps also have a way to interact with very low latency via event streams (Kafka), etc.

I have a long vacation before I join a new company that requires all that from me. I want to minimize my impostor syndrome once I get there, and I don't mind spending hours learning stuff that I'll need in order to be better than I was when I was offered the contract.

restive marlin
#

Alright, well here's my interpretation of the best way, maybe that will give you a place to start researching:

How do I make it work with high demand : The bottleneck in 95% of all cases with web-based applications in my experience is database transactions, generally very inefficient reads caused by some ORM magic. If you have high demand, make sure that your database interactions are as simple and minimal as possible. Ideally build your own ORM. Data processing bottlenecks are much less frequent that database issues

Where does async fit in: Honestly, anywhere where you are processing independent data. If you want to make async a little easier to deal with, it is best to work from pure functions (from functional programming) as it makes concurrency way more overseeable

What performance-related thoughts are also there: Generally, almost none. Readable code is way more important than performance. Tackle performance once it becomes a problem, not before.

How do I write proper tests for it: I recommend exploring tools like hypothesis and hypothesis-auto if you are dealing with input. As for coverage, I think good coverage is a reuslt of well-factored code. It is really easy to write a test for a pure function and really hard to write a test for stateful spaghetti. If you reduce the amount of stateful spaghetti by always factoring your code into as pure a state as possible, it will be easy to get good and reliable coverage

How do I deploy to the cloud properly: Terraform + gitlab CI/CD. If you need to manage servers, Infrastructure as code is invaluable. gitlab ci/cd is just neat in general.

#

That said, if you are already joining a new company, you will learn their best way soon enough. There will be plenty of experts there to help you out, so I would just nejoy your vacation if I were you ๐Ÿ˜…

fair oriole
#

Yeah, the part of Databases, and data flows, I got covered quite well, as that is where I'm one of the best in my field :D. Worked with Terraform, not so much with CI/CD but from looking at it before it seems quite simple.

I'll try to convince myself to write less stateful stuff.

Thanks! But I'll still be looking for good examples somewhere for what a high load microservice looks like.

restive marlin
#

Wish I could be of more help ๐Ÿ˜… Good luck though!

eternal frigate
#

@dense slate you could not use a webserver that supports SSL termination like NGINX?

dense slate
#

I ran into an issue where the web socket wouldn't load with ssl enabled.

#

But it was because of that specific library

eternal frigate
#

nginx would decrypt the message and proxypass to the websocket server

#

And the opposite too, encrypt it before sending to the client

weary blade
#

Hello I am writing because I have problem with flask psycopg2 anyone have a second to help me ?

somber aurora
#

who can help me with my django error DMe if you can

fair oriole
#

What's the purpose of nginx?
Right now, I have a DNS record that points a subdomain to the ip address of my server.
my nginx config on the server is just passing port 80 to port 5000 all on localhost
However, every config I've seen online passes it to a domain name
@native tide nginx is a very optimized web server. It runs its own user, and can listen to port 80. Your user can't, for security reasons. Nginx can handle a lot of configuration. Even if in this case there isn't much config, if you want to add another site on the same server - you can with nginx. If you want (and definitely SHOULD) enable HTTPS, nginx can handle SSL. Do the site in Python, handle traffic with nginx.

native tide
#

is it appropriate for me to pass to localhost

#

because all configs I've seen online use a domain name

fair oriole
#

if you do it always on localhost then you don't need nginx at all

#

for development you don't need nginx

native tide
#

it's for production

#

my web server is being hosted on a different port, and all I want to do is have it accessible on port 80, as well as use https

#

what I did was just pass it to the web server on the localhost

weary blade
#

Hello I am writing because I have problem with flask psycopg2 anyone have a second to help me ?
@weary blade BUMP

fair oriole
#

then nginx, 80 for http, 443 for https. But you should never run a site on port 80. Make port 80 always redirect to 443 instead.

native tide
#
events {

}
http {
    server {
        listen 80;
        server_name localhost;

        location / {
            proxy_pass http://localhost:5000/;
        }
    }
}
#

this is my entire nginx config rn

#

I don't know if this is the correct way to do it

fair oriole
#

@weary blade BUMP
@weary blade voice your question in one of the available #help-* channels. And start with actually writing the problem, not asking for help :).

weary blade
#

I have opened oxygen

native tide
#

then why are you still here

weary blade
#

And nobody is reading that even

native tide
#

because you're impatient

fair oriole
#

be nice

weary blade
#

me ?

native tide
#

as well as obnoxiously bumping your question in front of mine when I was in the process of being answered

#

but I guess that already goes with impatient

#

So why is it that when I see nginx configs online, they usually have a domain name as the server_name and proxy_pass?

fair oriole
#

@native tide you're being rude.

#

you want a good answer, take a help channel. Don't be mean to other members of the community.

native tide
#

Is it optimal to use WYSIWYG in your web app? The generated HTML is quite large

#

No, WYSIWYG is a terrible approach and frowned upon by actual front end devs

#

It might be usable for mock-ups

#

Mkay.. so it is better to use a pre-styled template for a post rather than letting wysiwyg generate the code for yourself.

#

Absolutely

#

If you're looking for good documentation on this stuff, I recommend Mozilla

#

documentation for?

#

HTML CSS and JavaScript