#web-development

2 messages Β· Page 135 of 1

toxic flame
#

I see.

#

Well. What is your opinion on the developer job's saturation? Is it really saturated? ( 2021-2022)

#

I still have a few years until i am old enough to apply for jobs

wicked elbow
#

theres not enough programmers. most programmers are just hobbyists

toxic flame
#

Haha alright

wheat swift
#

hi guys! any1 home?

I am trying to deploy a django app but im having trouble

gunicorn works when i use it inline with bash command: gunicorn -b /path/to/projectname/projectname.sock projectname.wsgi:application

but not when running on systemd service

also the systemd service says its running fine

wheat swift
#

so im deploying in a ubuntu hosted os

vestal hound
#

not using any PaaS solution?

wheat swift
#

the real thing im trying to figure out is where the .sock file is being created.

#

i use digitalocean droplets

vestal hound
#

ah

#

okay

wheat swift
#

thing is i want to share the nginx routes with this app

#

and my other things like resume site etc

#

😒 everything says active and green just dont know where the .sock is being created lol

vestal hound
#

like you want to use the socket

#

to communicate?

#

with your other code

wheat swift
#

omg..

#

I failed..

#

So idk why it's creating the .sock file somewhere else

#

gunicorn creates a file called .sock that is basically the server with various workers for a python flask/django app

#

i figured it out lol.

vestal hound
#

πŸ†

wheat swift
#

i basically used a grep command i googled to find all files that end with sock

#

.sock extension

#

and bam i found the thing it made :/

balmy hare
#

any selenium\requests-HTML users here?

tulip beacon
#

guys is anyone here good at react?

glacial orchid
#

Nope, giving an empty object

limpid heath
#

Is there any method for password hashing in flask?-

nimble epoch
#

there are flask-bcrypt and in werkzeug

small quail
#

i am new can anybody tell me how to open chrome??

#

without using selenium

#

??

native tide
#

Hello i need help for django

small quail
#

i am new can anybody tell me how to open chrome??
without using selenium

#

??

twilit needle
#

can someone please help me here?

small quail
#

i am new can anybody tell me how to open chrome??
without using selenium

#

??

nimble epoch
small quail
#

ok

thorny lake
#

you can use splinter

twilit needle
#

the question is related to drf

#

anyone familiar with it here? can someone please help?

thorny lake
#

data request form?

lofty marten
#

Hi just want to ask a question for web developers. before you get into your job did your company uses a tool to assess your knowledge? what was is and what company? thanks for the help

dull tartan
dull tartan
native tide
#

Who is good in django

wicked elbow
tulip beacon
ocean blaze
#

@tulip beacon ^

native tide
hollow relic
#

Hi, i wanted to learn mobile development and was wondering if react was a good choice. I would only use this framework to create UIs and animations, while the sauce of the app would be written in C. Any of you know if this is possible, if it is, which frameworks do you advise?

native tide
#

react is good, but for me i use flutter

#

just depends what you like

hollow relic
native tide
#

no

hollow relic
#

regarding janky animations?

native tide
#

works fine for me

hollow relic
#

ok, thanks

native tide
#

but i dont know if you can write c with it can you?

#

@hollow relic

hollow relic
#

tht's what i'm trying to figure out ahah

#

i just need a simple framework to deploy good user experience in short times

#

then i'll migrate to native kotlin and swift

native tide
#

yeah i dont think you can use just c like that, you have to use the backend that react supports and i think it is react.js

native tide
hollow relic
#

i'll make some research, thanks for your help. If anyone else knows more please dont be shy

alpine kestrel
#

Hello Guys! I'm learning DJango REST by building a WebApp.
I've made some views using viewsets.ModelViewSet to use its default actions ( create )
One of my WebApp Models has a ForeingKeyField ( a common AbstractUser id ). What i'm trying to do is to test the creation of that model using APITestCase but I'm getting a response back with a 400 Bad Request status code.
Is possible to create a model instance that has a ForeignKey using the default actions from ModelViewSet? or should I create a custom create action for this?

crude crane
#

Hi

#

What do you guys think of the official Flask docs

twilit needle
#

hey

#

can someone please help me here with drf?

void summit
#

hello

turbid estuary
#

hey, what is the real time moving stuff in a webpage called?
like a real-time chat, what is that element(?) called in web language?

void summit
#

I'm looking for some help on django, any ideas where to ask ?

turbid estuary
void summit
#

I'm having some issues with migrations, the idea was to create a new user model, when I execute manage.py migrate I get this error

django.db.migrations.exceptions.InconsistentMigrationHistory: Migration admin.0001_initial is applied before its dependency users.0001_initial on database 'default'.
#

found on google some solutions but I don't think it's the right way to do things. In order to solve it you have to reset migrations and re-migrate everything again ...

#

I don't think it's something anyone want to do on production ..

#

looks like it's not something simple, at least not automatic

regal fox
#

hello

#

i need help

#

for django

dense mica
#

anyone with good knowledge about a python flask project and deployment in heroku? Seems like I cant get it to work after the last deployment including authentication with jwt tokens. I cant post anything to the postgres db anymore :/

scarlet breach
#

Hey I had a question,

If I'm into web dev and related stuff should I learn CSS? I'm not sure if CSS is exclusively used for web dev but I think it majorly does?

echo river
lusty valve
#

Which one is better?
Flask or Fast API ?

native tide
native tide
dire violet
#

Hey im looking for a tool to a) create charts for statistics (like google charts) and b) able to code everything in python (pls no javascript ...)

echo river
#

Hi, I facing some issues regarding Django. When I tried to run, it prompt "No Such Table on XXX". Solution that i have taken:** 1. Python manage.py make migrations/ migrate . 2.** Make sure the APP added into INSTALLED_APP.** 3. ** Delete entire migrations done and re-done the step 1

lusty valve
native tide
#

You are building what for social media?

#

Simple api or more complex project with login, likes posts etc

lusty valve
#

like the user registration ,login and chat ?

#

and some other features

native tide
#

So then better to use like django

lusty valve
#

ikr

native tide
#

Because that is web framework and will make it easier to do all this

lusty valve
#

but what if i need to choose between Flask and Fast API

#

like django is more complex

native tide
#

Use flask then over fast api

#

Because you will need like front end views etc

echo river
#

BI ?

#

Power BI ?

native tide
#

Why can’t you use js but?

dire violet
#

because i dont know anything about js and it seems like cancer tbh

native tide
#

You just need to pass data from python to it

#

Oh ok

dire violet
#

yes but how?

#

i got the basic charts in an html file working, but i dont konw how to feed it data

native tide
#

The JS is part of your view yes?

dire violet
#

JS is part of my html, which just displays a google chart

#

and it takes data, specified like this:

native tide
#

Do you have like a controller or anything like this which tells python to show this html page etc?

dire violet
#

var data = google.visualization.arrayToDataTable([
['Genre', 'GorillaTraps', 'PestCam', 'Beep', 'Direct',
'Pro', 'FuturaCam', { role: 'annotation' } ],
['2020', 10, 24, 20, 32, 18, 5, ''],
['2021', 16, 22, 23, 30, 16, 9, ''],
['2022', 28, 19, 29, 30, 12, 13, '']
]);

and i want to replace the pre defined list (genre, otraps etc.) with something from like a python list

#

but i dont know how to connect this html file with javascript with some json out of python

#

i got an html file with one chart from google in javascript
and i got a python script that uses api calls for json files
this json files contains the data i need to feed "into" the javascript thing

#

the javascript data is the thing i just pasted

#

right now its hardcoded

native tide
#

What are you using django/flask or what

dire violet
#

nothing so far, only html

native tide
#

Eh

#

So your not coding in python then?

dire violet
#

i really dont know alot about web development regarding python

#

so youre recommending django?

native tide
#

No

#

Depends what you are working on

limber laurel
#

I am trying to cache using memcached in django, but for some reason when I try to get my key it returns None

dire violet
#

im working on a website that needs to display statistics that i get from a large json api call

native tide
#

There is different options available but you have decide which is good for you

#

Ok so then flask will be good for this

#

Easy to do and less complexity

dire violet
#

thank you, ill look into it

#

i was just looking for some suggestion like this

native tide
#

Ok no worry

#

Basically you will have a python file where you can pass data to the html and in the html file you can pass data to the js script

dire violet
#

ok i see, so i should look into: how to transfer data from pytohno to html and how to transfer in html to javascript

#

right?

native tide
#

I don’t know what is pytohno

#

But you don’t really pass from html to js, the data will just be available for you to pass to the js

dire violet
#

problem: these charts in flask look like ****

#

Dash python seems to fit my problem

scarlet breach
toxic flame
#

Everyone usually do fronted dev though, because it's easy. Not everyone can do backend

gloomy orbit
#

where can i start learning django?

scarlet breach
#

i wanna kinda do both like you know what i mean i wanna learn everything there is

toxic flame
echo river
toxic flame
#

Or youtube videos are an option too

echo river
#

What I heard from some experts that, Django poll project are too complex for beginner

#

Best way to learn, gets your hand dirty, create various tiny project

umbral mulch
#

Does anyone know why my forn is neverbeing validated?

#

@app.route("/", methods=['GET', 'POST']) 
def home():
    form = ReusableForm()
    if form.validate_on_submit():
        answer1 = form.Num1 + form.Num2
        flash(answer1)
    return render_template('math.html', form = form)

class ReusableForm(FlaskForm):
    Num1 = TextField('Num1')
    Num2 = TextField('Num2')
    submit = SubmitField('Submit')

#
{% with messages = get_flashed_messages(with_categories=true) %}
            {% if messages %}
              {% for category, message in messages %}
                  {{ message }}
              {% endfor %}
            {% endif %}
          {% endwith %}

<form action="/">
    {{ form.Num1 }}
    {{ form.Num2 }}
    {{ form.submit}}
</form>
#

I think my form is just getting, NOT posting

quasi stratus
dawn heath
umbral mulch
#

<form action="/", methods=["POST", "GET"]>

quasi stratus
#

action="/" method="POST"

#

I think you have a mess in your head regarding html vs python

#

Please make sure you understand where is which

umbral mulch
#

yeah

#

sorry

#

I did that

#

it didnt work

#

So I get the same result

quasi stratus
#

It should work after you submit the form

umbral mulch
#

<form action="/" method="POST">
{{ form.Num1 }}
{{ form.Num2 }}
{{ form.submit}}
</form>

#

sendign a video rn

quasi stratus
#

Is there output from the server side?

umbral mulch
#

if form.validate_on_submit():
is never happening i beleive

quasi stratus
#

Look at server output or log

umbral mulch
#

how can i do that this is locally hosted

#

im very new to this

quasi stratus
#

Server is the process, where python runs

#

Terminal maybe

#

You should see some log where it says GET or POST for each request

umbral mulch
#

127.0.0.1 - - [19/Feb/2021 13:49:14] "POST /?Num1=1&Num2=1&submit=Submit HTTP/1.1" 200 -
127.0.0.1 - - [19/Feb/2021 13:49:15] "POST /?Num1=1&Num2=1&submit=Submit HTTP/1.1" 200 -
127.0.0.1 - - [19/Feb/2021 13:49:16] "POST / HTTP/1.1" 200 -
127.0.0.1 - - [19/Feb/2021 13:49:16] "POST / HTTP/1.1" 200 -
127.0.0.1 - - [19/Feb/2021 13:49:17] "POST / HTTP/1.1" 200 -

#

im getting LOTs of post requests

#

that means it is posting indeed

quasi stratus
#

Yes, for each click on the submit button

umbral mulch
#

yes. I am not able to find the problem here

quasi stratus
#

Probably validate_on_submit returns false

#

You can add print statement to check that

umbral mulch
#

yes it returns false

#

i tried that

quasi stratus
#

Well, I'm not familiar with that function. You'll have to dig into docs to understand how it supposed to work

umbral mulch
#

thank you for your help @quasi stratus

quasi stratus
limber laurel
#

I am trying to run memcached on windows, but I keep getting this when I try to run memcached.exe -d start, I get failed to start service

#

any ideas of what could be causing this and what could be done to fix this?

silver pollen
#

@limber laurel what about memcached -d install ?

limber laurel
#

I got the error
Failed to install or already installed @Erik85#7591

limber laurel
silver pollen
#

@limber laurel ok that was the next thing i was gona suggest. no idea then.

native tide
#

https://sourceb.in/cXfEbhEItZ
on line 57 im getting an error saying await can only be used in an async function
but idk where to add async
so can anyone help?
please and thanks

#

ping if u can answer

warm fractal
#

Reask from #python-discussion

Anyone aware of a json pretty printer that enables Conditional compact of objects with specific properties

native tide
#

hey guys. Suppose i have a list of objects 'movies' ```js
const movies = [
{
_id: "5b21ca3eeb7f6fbccd471815",
title: "Terminator",
genre: { _id: "5b21ca3eeb7f6fbccd471818", name: "Action" },
numberInStock: 6,
dailyRentalRate: 2.5,
publishDate: "2018-01-03T19:04:28.809Z",
},
{
_id: "5b21ca3eeb7f6fbccd471816",
title: "Die Hard",
genre: { _id: "5b21ca3eeb7f6fbccd471818", name: "Action" },
numberInStock: 5,
dailyRentalRate: 2.5,
},
{
_id: "5b21ca3eeb7f6fbccd471817",
title: "Get Out",
genre: { _id: "5b21ca3eeb7f6fbccd471820", name: "Thriller" },
numberInStock: 8,
dailyRentalRate: 3.5,
},
{
_id: "5b21ca3eeb7f6fbccd471819",
title: "Trip to Italy",
genre: { _id: "5b21ca3eeb7f6fbccd471814", name: "Comedy" },
numberInStock: 7,
dailyRentalRate: 3.5,
},
{
_id: "5b21ca3eeb7f6fbccd47181a",
title: "Airplane",
genre: { _id: "5b21ca3eeb7f6fbccd471814", name: "Comedy" },
numberInStock: 7,
dailyRentalRate: 3.5,
},
{
_id: "5b21ca3eeb7f6fbccd47181b",
title: "Wedding Crashers",
genre: { _id: "5b21ca3eeb7f6fbccd471814", name: "Comedy" },
numberInStock: 7,
dailyRentalRate: 3.5,
},
{
_id: "5b21ca3eeb7f6fbccd47181e",
title: "Gone Girl",
genre: { _id: "5b21ca3eeb7f6fbccd471820", name: "Thriller" },
numberInStock: 7,
dailyRentalRate: 4.5,
}
];

#

I want to get a certain movie depending on the _id

#

and return it's index

native tide
#

yes

vestal hound
#
movies.map((e, i) => [e, i]).filter(([e, i]) => e._id === id)[0][1]
#

@native tide this should work

native tide
#

ok

#

yesssss it does

elder echo
#

Is Flask complicated?

#

Ive been trying to get into it

#

BUt I just dont know what IM doing

#

Am I taking the wrong approach?

toxic flame
#

Flask is easier than django

silver pollen
#

it took me a while to figure out the app factory pattern in Flask

#

and how to get it working with flask-sqlalchemy

#

but once that's in place it's a solid setup

fickle fjord
#
html
<div id = "video"><iframe width="300" height="300" src="https://www.youtube.com/embed/rUWxSEwctFU" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe></div>
<div id = "button"><button type="button">Click Me!</button></div>

css 
#button{
background-color: bisque;
padding: 12px 28px;
border-radius: 15px ;
font-size: 24px;
position: absolute;
left: 100px;
up: 30px;

}

``` Javscript
(function showPlayButton() {
    if (document.getElementById('video').ended) {
        document.getElementById('button').style.display = 'block';
    }
    setTimeout(showPlayButton, 1000);
})();
``` can someone explain why it isnt working?

#

I want the button to appear once the video finishes

elder girder
#

I want to make a website for mainly personal use, can someone point me in the right direction to start learning how to do that?

ionic thicket
#

has anyone created an authenticated flask page with pysaml2 & okta?

#

the pysaml2 docs aren't so easy for me to follow

outer pier
#

guys anybody have experience in django websocket and redis channels ?

onyx gulch
outer pier
#

Rabit MQ !! what is it used for dude

blissful escarp
#
print("Hello")
onyx gulch
outer pier
#

for sure dude . Thank you for responding

tiny bridge
#

Hello, can anyone help me with Flask deployment? I built a simple Flask app and it runs locally but I've been trying to deploy it since yesterday to no avail. I tried both PythonAnywhere and Heroku

twilit needle
#

or on github regarding the same

regal fox
loud bridge
#

Hey

#

Is there a way to use html forms with python

#
<form action= pythonfile.py method = get>
#

And then collect the data and do whatever I want to do with it through python

amber oxide
#

What should I do when my django app lost connection with database?

north summit
#

hey devs what is difference between static and dynamic site

regal fox
#

static is

#

is way cheaper and has a better fire wall

#

than dynamic

#

so basicly static is beter

modest mason
#

πŸ‘‹ hey all new here and new to python (I'm a designer/front-end). If this is not the correct channel let me know!
I'm building a rest api with flask and I'm struggling a bit with how to structure my files, imports, etc. Currently I have something like:

app
|_ /models
   |_ <models go here>
|_ /routes
   |_ users.py
   |_ recipes.py
   |_ ...
|_main.py

I'm initialising my app in main.py

# Init app
def create_app():
    app = Flask(__name__)
    CORS(app)
    app_config = DevelopmentConfig
    app.config.from_object(app_config)
    jwt = JWTManager(app)
    db.init_app(app)

    from app.routes.users import user_routes
    ...
    return app

but then... how do I import jwt on routes/users.py when I want to do something like @jwt.user_identity_loader??
As I understand it, I could write something like this, so I can extract the user id from the auth token:

@recipe_routes.route('/', methods=['GET'])
@jwt_required()
@jwt.user_identity_loader
def get_recipes(user):

I don't want all my routes to be inside main.py's create_app but on a different file, but as jwt is init there... I have no clue how to import it on a different file. Hope it makes sense, I'm brand new to python/back-end dev πŸ˜…

halcyon lion
#

boys help me

#

i have to write js

#

how to test a property of an object πŸ˜„

#
const numberOperations = {
    powNumber: function (num) {
        return num * num;
    },
    numberChecker: function (input) {
        input = Number(input);

        if (isNaN(input)) {
            throw new Error('The input is not a number!');
        }
#

how to access this numberChecker

amber oxide
amber oxide
amber oxide
# halcyon lion boys help me

const numberOperations = {
powNumber: function (num) {
return num * num;
},
numberChecker: function (input) {
input = Number(input);

    if (isNaN(input)) {
        throw new Error('The input is not a number!');
    }

}

halcyon lion
#

man i am so lost πŸ˜„

#

this javascript is not my language πŸ˜„

amber oxide
#

Language is just a tool

dreamy herald
#

I have a question about url patterns on django:

I'm trying to access api/token but it's using the wiki.api.url view instead of the TokenObtainPairview. I thought that with the order I should be able to access the tokens?

    path('api-auth/', include ('rest_framework.urls')),
    path('admin/', admin.site.urls),
    path('api/', include('wiki.api.urls')),
    path('api/token/', TokenObtainPairView.as_view(), name='token_obtain_pair'),
    path('api/token/refresh/', TokenRefreshView.as_view(), name='token_refresh'),
    path('wiki/', include('wiki.urls')),
]```
neon isle
#

Hello
how do I get discord users guilds in django allauth ?

rich warren
#

Hello! what things do you usually log in every request in your webapp? I'm guessing request_id and host and env but what else?

noble smelt
amber oxide
#

for*

opaque rivet
verbal coral
#

Hey guys i'm learning django right now and this error suddenly appeared on my models.py, asgi.py, and wsgi.py (they all say the same error when i visit each file) why is it like this? I just wanted to connect to mysql and insert some data

verbal coral
#

Oh thanks @bright cloak

#

i finally got running

quiet ridge
#

Hey can someone please tell me what type of web apps are needed in 2021 for common use ?

toxic flame
toxic flame
brittle fiber
#

just use html

swift nebula
#

if you guys were to pick from python or php as back-end, which one will you choose as an easier language?

#

im really having trouble using python django with connecting it to my db

toxic flame
#

def django

#

definetly

#

php was my first language but seeing the ease in django and it's rapid in production... I prefer django.

#

But php is a bit faster than python

covert leaf
#

As a backend, I have really been liking FastAPI. Interops well with most of the expected tools and chains for the most part.

swift nebula
#

im really getting confused on django because of too many path

#

also with those generated stuff that i didnt know

#

like this, django automatically generated these tables

#

anyway, i think i'll be familiarizing first with php and eventually try to switch to python when im experienced

toxic flame
#

if that's what you want

swift nebula
#

we're lacking in time and someone said php is bit faster

#

oh ur the one lel

#

anyway thanks!!

toxic flame
#

by a bit

#

I meant nanoseconds

swift nebula
#

but will it have some generated tables like django did?

covert leaf
#

If you are looking for a php based framework, I would suggest Laravel if you wanted something in the same realm or equivalent to Django

swift nebula
#

i'll look into that

#

thankss

toxic flame
toxic flame
#

Django can also not have premade tables... That's because you used the default django settings it has them premade.

opaque rivet
#

There are more positions for laravel jobs but you will be paid less compared to django, in the UK anyways.

quiet ridge
spare iris
#

at 7:25 he types cd Flask_Blog/

#

and it works in his terminal

#

but when i try it nothing happens

#

it says no file or directory

#

confusion

#

i'm just trying to follow the tutorial

opaque rivet
#

What's your file structure?

#

Send a ss

glossy arrow
#

^

spare iris
#

how do you see the file structure

#

sorry am big noob

#

yeah i don't know how to see the file structure on VSC

ripe jasper
#

Anyone working as py developer ping me

spare iris
#

that's not it

#

does that help???

#

how do you even see the file structure in vsc

#

ugh i have another question

#

here corey types $ flask run

#

but when i type $ flask run it says command not recognized

noble spoke
#

is flask installed

spare iris
#

yes

noble spoke
#

are you sure? try opening the interpreter and importing it

spare iris
#

yep i imported flask

#

it just says command not found on the terminal

noble spoke
#

are you typing in $ flask run or just flask run

spare iris
#

the first option

#

should i try the other

noble spoke
#

do the second one

#

the $ is just his shell prompt

spare iris
#

Error: Could not locate a Flask application. You did not provide the "FLASK_APP" environment variable, and a "wsgi.py" or "app.py" module was not found in the current directory.

noble spoke
#

like >>> is for the interpreter

#

you need to set the FLASK_APP env variable

#

and the FLASK_ENV if you want

spare iris
#

ok i think i got it

#

thanks

#

@noble spoke the problem was my dumbass using a $

#

sorry am noob to flask

noble spoke
#

lmao its ok

toxic flame
#

just run the .py file

#

just run flaskblog.py and it will work correctly ( on the cmd )

spare iris
#

could not import flaskblog

#

big mad

#

oh i may be stupid again

#

i called it flaskblog

#

did i just dox myself

#

whoops time to change my name

#

anyways why is this wrong

#

i'm mad

#

i don't know why i can't figure it out

#

i swear if i cannot figure this out by tomorrow i'm doing more hackerrank

#

nah jk

#

does anyone know

toxic flame
#

lol

#

If you know how to do hackerrank why don't u know how to do this

#

This is really the basics...

#

I just read a 5 min art on flask and i can do stuff in flask now

spare iris
#

i don't know how to do hackerrank

#

i don't need you to shame me for not being able to do the basics

#

what do you want me to say? congrats?

noble spoke
#

less talking more reading if you wanna get anywhere with this

spare iris
#

what do you think i've been doing

#

from flask import Flask
app = Flask(__name__)

@app.route("/home")

def home():
    return "Hello!"

if __name__ == "__main__":
    app.run()
#

when i type in flaskblog.py as my file name in the terminal it says command not found

#

that's what techwithtim does in his video

#

it's this video

#
SyntaxError: invalid syntax
>>> /opt/anaconda3/bin/python "/Users/rahuldas/visual Studio worskpace/Web App Drawing/flaskblog.py"
  File "<stdin>", line 1
    /opt/anaconda3/bin/python "/Users/rahuldas/visual Studio worskpace/Web App Drawing/flaskblog.py"
    ^
SyntaxError: invalid syntax
#

I’ll read more flask stuff before asking more questions

spare iris
#

so do web apps count as full stack

#

what is full stack

calm hedge
#

@spare iris full stack is when you develop both the front and back end

spare iris
#

oh

#

ok

#

i was following this tutorial

#
  • Serving Flask app "hello" (lazy loading)
  • Environment: development
  • Debug mode: on
  • Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)
  • Restarting with stat
  • Debugger is active!
  • Debugger PIN: 813-894-335
#

this is what it said

#

i clicked on the link expecting to see hello world but i saw something else

#

i'm confused

#

i guess this is just too basic to help with huh

noble spoke
#

Ok

#

Theres one thing you have to do everytime you restart your terminal for flask

#

Env variables dont persist, you need to re export them

spare iris
#

what is exporting

#

i know importing

#

i will google that

noble spoke
#

export FLASK_APP=flaskfile

#

On macos its export

#

On windows cmd its set

spare iris
#

export FLASK_APP=hello

noble spoke
#

The flaskapp var is supposed to be the file name

#

Its called the "entrypoint" to the application

spare iris
noble spoke
#

Yes

spare iris
#

ok

noble spoke
#

Set it, all caps in the name (FLASK_APP)

#

Then reload

spare iris
noble spoke
#

No, flask looks at the environment variables for one named FLASK_APP

#

Its very specific, dont forget it

spare iris
#

ok

noble spoke
#

Terminal

spare iris
#

-bash: export: `=hello': not a valid identifier

noble spoke
#

export FLASK_APP=flaskblog.py

#

In the terminal

spare iris
#

oh i'm stupid

#

i thought they were naming it after a function not the file name

#

ok that worked

noble spoke
#
export FLASK_APP=flaskblog.py
export FLASK_ENV=development
flask run
spare iris
#

and you need that basically every time

#

you run something on flask

#

flask.cli.NoAppException: Could not import "flaskblog".

#

i still see this

#

i copy pasted what you gave me

#

i will google that

#

no it should work

noble spoke
spare iris
#

web app drawing is a folder

noble spoke
#

Broski

#

Thats the interpreter

#

exit() and flask run

spare iris
#

in the terminal?

noble spoke
#

If you look to the right, it says "Python"

spare iris
#

OH

noble spoke
#

Its the pythonshell

spare iris
#

is that where you're supposed to do it

#

i was doing it in the terminal that comes w the mac

#

not the IDE

noble spoke
#

That works too

#

But not the python shell

#

Type in exit()

#

And then flask run

spare iris
#

bash: syntax error near unexpected token `flask'

noble spoke
#

Screenshot

spare iris
noble spoke
#

Your app is running

#

Ok just pick a terminal and stick with it

#

Either the ide integrated terminal or the other one

spare iris
#

let's just do the ide one

#

it's still asking for a flask app environemtn variable

#

so let's give it one

noble spoke
#

Ok, do that again and then flask run

spare iris
#

sorry i'm being annoying

#

why is the damn syntax so particular about spaces

#

it's hella annoying

#

OSError: [Errno 48] Address already in use

#

what does that mean

noble spoke
#

It means you need to kill the other terminal

spare iris
#

i closed it

#

Not Found
The requested URL was not found on the server. If you entered the URL manually please check your spelling and try again.

#

uhhhhh

noble spoke
#

Did you go to the proper address

spare iris
#

i copy pasted the link that came from the terminal

#

i'm hella confused

noble spoke
#

Show me the screen

spare iris
noble spoke
#

Show me the url too

spare iris
noble spoke
#

Did you change the code?

spare iris
#

i tried adding http://

#

no

#
from flask import Flask
app = Flask(__name__)

@app.route('/')
def hello():
    return 'Hello, World!'

if __name__ == "__main__":
    app.run()

#

this is the same code as before

#

i don't get it

noble spoke
#

I cant see anything wrong

noble spoke
#

Close the editor and restart it

spare iris
#

ok

#

AYYYY

#

IT DID IT

noble spoke
#

What tutorial are you following

spare iris
#

YAY

#

a goodie

#

thanks @noble spoke

noble spoke
#

πŸ‘Œ

spare iris
#

ok now i have to think of how i want the website to look

#

does this mean i have to learn HTML again

noble spoke
#

Yes

#

And css

spare iris
#

ok no problem

#

shouldn't be too bad

#

and i can ask all those questions here right?

noble spoke
#

I guess?

spare iris
#

yay

dreamy herald
# noble smelt Where is this file in ur directory? Is it the main urls.py file?

@amber oxide @noble smelt , this is in the main urls.py. I used postman to check the end points that that's how I worked out it's going to the wrong spot.

I get this if I move the api/token url above the api/ url

    "username": [
        "This field is required."
    ],
    "password": [
        "This field is required."
    ]
}``` 

but then I get a 

```    "detail": "Method \"POST\" not allowed."

if the api/ url is above the api/token

wanton forge
#

does anyone know how you can have an interactive window on your website where the user can input a few things, submit it, have that info sent to the backend to do calculations on a database, then send back the results to the user?

echo hound
strong torrent
#

@noble spoke So I got the webhook to be working with flask, but when I put it into the website, it wasnt able to send anything. I am using the url which is:
http://198.84.238.98:5000/webhook Why isnt it working?

wanton forge
cinder whale
#

jk flask is good to learn

#

but i think django is more popular in industry

spare iris
#

well i need to start w somehting

#

i can do django when i do my internships web app

#

a web app that helps users find internships

#

@cinder whale that is my new favorite gif

noble spoke
#

@strong torrent i suggest looking into Postman

strong torrent
#

Ok

noble spoke
#

Its a tool that helps you test http requests

strong torrent
#

Ok

noble spoke
#

Its easier than writing curl requests

strong torrent
#

Ok I will try

strong torrent
echo hound
noble spoke
#

@strong torrent you can try opening the developer tools and looking at the network tab for the request the website sends out

#

And see whats not working

pseudo nexus
#

Hi

strong torrent
pseudo nexus
#

are there Russians here?

strong torrent
#

Idk

noble spoke
#

Yea next to the console

#

In the browser

#

Theres a network tab

cinder whale
#

i mean i will learn flask probably before django too

#

my prof is going over it in class later in the semester

noble spoke
#

Youre getting taught flask in uni?

spare iris
#

hahahhaha laughs in business major

cinder whale
#

this is grad school, so yes

strong torrent
#

Oh ya

cinder whale
spare iris
#

i got taught bottle

strong torrent
#

I just noticed that

noble spoke
#

Bro when i was in uni the only webdev they taught us was java server pages lmao

pseudo nexus
#

Why are such commands that others have highlighted in blue I do not stand out that is, sender, VkApi...?

cinder whale
#

uhh maybe highlight over it, and it will tell you?

#

i dont actually use sublime as much

pseudo nexus
cinder whale
#

the bot isnt reading it?

#

maybe it is the api

#

could be many things

pseudo nexus
pulsar copper
#

In my Flask webapp, I've got a function called process_user_query() in my app.py script which currently handles POST request from a user's **query ** submitted through a HTML form and then calls a different function, display_query_results() to execute some processes and render a different page to the user.. Now I don't want to reload the page nor do I want to redirect the user anywhere.. instead, I just wanna take in the user input from the search box using the process_user_query() in the app's main script and then call display_query_results() to show some content to the user... is this possible to do simply using Python? No, right?

#

How might I be able to use JS's Fetch API to handle this?

past cipher
#

you could post it silently by wrapping the form in a iframe, and then setup a listener in JS with the route you want to results from. Or you could use Ajax to make the post request and get the response from the route @pulsar copper

pulsar copper
#

Sooo there are lots of ways to retrieve requests and display the response back to the user in webpages, I take?

past cipher
#

fetch can't do post requests anyway

#

afaik

#

fetch for get I would do something like this

async function getView(){
  const f = await fetch('/url')
  const response = f.text()
#

actually yeah fetch can do post requests, my bad I always thought you had to use ajax

pulsar copper
#

So how might it work with the way I want it to do?

past cipher
#

JS isn't my strongest, but I would try this:

async function getView(){
  const f = await fetch('/url'. {
      method: 'POST',
      headers: {
        'Accept': 'application/json',
        'Content-Type': 'application/json'
      },
       body: JSON.stringify({
          somethingtopost: value,
          somethingtopost: value
      });
  const r = f.json() // depending if the response is json, or use f.text()
wicked elbow
#

any suggestions to make it look more modern? just cant shake that it just doesnt look quite right

wicked elbow
vestal hound
#

I think a big part of it is the colour scheme tbh

#

more or less every popular social media platform I can think of does not use green tones

wicked elbow
#

thats whats good about green its different

#

haha

vestal hound
#

hm

#

well

#

@ this point people associate green with like

#

restaurants

#

outdoors

#

okay the thing also is that it's a very

#

dark, kinda muted green

#

which wouldn't be out of place on, say, a meditation website

wicked elbow
#

i just dont wanna do blue... i dont wanna look like facebook

vestal hound
#

ye that's fine

#

how about try

#

more pastel colours?

#

just an idea

#

not sure if it'll work

#

the green quite turns me off tbh

#

also consider

#

different chat bubble colours

#

for incoming and outgoing

#

also

#

I don't thnk

#

you need another div

#

like

wicked elbow
#

yea, i havent fully jumped on the green either tbh. i tried that as well

vestal hound
#

the scrollbar should be over the whole container

#

but the input should be sticky to the bottom

#

you have extraneous whitespace

wicked elbow
#

the different colored messages. it looked worse then the grey and green

vestal hound
#

wait

#

okay if I look closely

#

outgoing is green

#

incoming is grey?

#

they looked the same to me at first

wicked elbow
#

yea

vestal hound
#

maybe turn up the saturation a bit?

wicked elbow
#

very light colored to keep the black text

vestal hound
#

or decrease the luminance of the incoming

#

also

#

I would say this

#

it is a pretty stupid convention

#

to make outgoing messages more striking (in terms of background)

#

because you know what you sent

#

what you care about is what the other person sent

wicked elbow
#

i think part of that is the paint screenshot save

vestal hound
#

so THAT should be the one with the more obvious background

#

that said

#

most social media websites disagree with me

#

or maybe they just didn't think about it

#

shrugs

wicked elbow
#

i thought the grey was more obvious, easier to read. is it backwards?

#

thats a bad example cause neither person has profile images

vestal hound
#

I suppose the question is which stands out more

#

against hthe background

#

but

#

minor point iMO

vestal hound
wicked elbow
# vestal hound what do you think about this

i thought thats basically what i did. scrollbar doesnt even exist unless it reaches the max height. but yea, i could shrink some of the white space between the input and the text box

vestal hound
#

the chat box should be everything below the header

#

like I'm presuming your structure is something like

#
<header>
    header
</header>
<section>
    <div id="messages">
    </div>
    <div id="input-container">
        <img>
        <input>
        <button>
    </div>
</section>
wicked elbow
#

its set up or basically

-----Header-----
  ---Links---
  ---  ------
  ---  ------
  ---  ------
vestal hound
#

#messages shouldn't have padding

#

and #input-container should be sticky

#

IMO

wicked elbow
#

thats the whole page, yes im still not set on coloring yet. its just a placeholder more then anything

#

the page as a whole looks dated

vestal hound
#

the colours make me feel ill

#

box-shadow seems a bit too much

#

the footer is πŸ₯΄

#

the header is a bit πŸ₯΄

wicked elbow
#

lmao yea, working on the colors

vestal hound
#

THE TEXT PADDING IS ALL OVER THE PLACE

#

LOOK AT THE RED HEADER VS THE GREEN HEADER...

#

😑

wicked elbow
#

no padding is uniform. the font size is what makes it the look different

vestal hound
#

...the padding is the same?

#

I find that quite hard to believe

#

look at the distance

#

between the first letter

#

and the left border

#

of the container

wicked elbow
#

no seriously though. it does look different, couldnt tell you why, but the padding is the same. checked in dev tools

#

actually the left padding is different yes, smaller container less padding

vestal hound
#

IT'S DEFINITELY SMALLER

wicked elbow
#

the padding is off though on the green one, gonna look into it. gotta be a stacked thing though because it looks normal with a profile pic there

vestal hound
#

I think the fact

#

that your colour scheme

#

doesn't really make sense

#

contributes a lot to the "old website" look

#

having three primary colours in close proximity to each other is πŸ₯΄

wicked elbow
#

thats instagram for you though. they just use a mostly white scheme these days. im no designer though

#

i found the extra padding as well, looks much better without it

vestal hound
#

I dont' see that on Insta

wicked elbow
#

3 colors, the sites scheme follows those colors. just not in headers. havent seen insta in a while. cant login there or facebook

#

but most sites use a plain white layout

vestal hound
#

yeah

#

like I think

#

having three colours

#

like

#

a triadic colour scheme

#

is a bit

#

bold

wicked elbow
#

yea, idk im not a designer by any means, i just code until it looks halfway okay normally

vestal hound
#

neither am I

#

but

#

well I had to learn since nobody else is doing it

#

πŸ₯΄

wicked elbow
#

lmao yea. biggest difference between my site and most others is mine is 100% coded by me. not using bootstrap ect. but thats also where the errors lie

toxic flame
#

Does the site work without reloading?

wicked elbow
toxic flame
#

What did u use?

wicked elbow
#

react

toxic flame
wicked elbow
#

the site is react/axios/rest framework/django

toxic flame
#

For the noreload thing

#

ah

wicked elbow
#

its actually redux that uses axios, but still

#

theres like 350 files to make the site run

vestal hound
#

I'm kidding

wicked elbow
#

no react and bootstrap arent the same thing though... react is a framework, bootstrap is premade html/css/js

#

lmao

toxic flame
#

React is technically premade javascript

#

jkjkjk xd

vestal hound
#

I think when you say "100% coded by me"

#

it would imply no frameworks of any kind

wicked elbow
#

almost rather build static pages then to write react components. but then its slow

vestal hound
#

i.e. pure DOM manipulation with vanilla JS

toxic flame
#

It's possible with vanilla php too

wicked elbow
#

django is a framework, so is rest framework by that logic

vestal hound
#

it is

#

like

#

IMO React and Bootstrap are on the same footing

toxic flame
#

no

#

imk

#

imo

wicked elbow
#

i use only my own programming. no prebuilt components

toxic flame
#

yea

#

bootstrap unlike react... Is a prebuilt design and components yea

wicked elbow
#

you dont need to know programming at all to use bootstrap, you have to know html/css/js/jsx to program in react even in the most basic aspects

vestal hound
#

okay, fair enough

wicked elbow
#

man i removed the white space in that, and it doesnt look good. definitely needs some white space, just maybe a little less

wicked elbow
#

see no white space looks bad. would look good as like a pop up chat, but not so much as an element

vestal hound
#

increase padding

#

hm

#

I would say with more padding it'd look okay

#

but your choice

wicked elbow
#

but thats what i already had lmao. just white padding instead of slightly offwhite

vestal hound
#

okay I guess

#

you could just make the background white

#

also increase chat bubble padding I think

#

seems a bit cramped

wicked elbow
#

yea i thought that too, but its already at 4px

#

see something like that looks better

vestal hound
#

uh

#

well

wicked elbow
#

i dont like the scrollbar on the edge of the element. it looks bleh

spare iris
#

ok then add a new one

wicked elbow
#

lmao that scrollbar is edited already to get rid of the arrows and make it smaller. lol i meant without the white space like in that picture.

spare iris
#

First, in your flask_blog directory, use nano or your favorite editor to create and edit your app.py file. This will hold all the code you’ll use to create the blogging application:

#

what does that mean

#

i got it from here

#

i'm confused

#

what flask_blog directory

#

i'm so confused

muted grove
#

It's the first thing under prerequisites

muted grove
#

That has no bearing

#

it literally says "A Python Programming environment". For you, that's in VSC

#

They are just calling the main project directory flask_blog

#

you can call it whatever you want

spare iris
#

ok?

muted grove
#

thats the answer to your question

spare iris
#

i fixed it already

#

but thanks

opaque rivet
#

i used to bash my head writing so much css etc.

#

used ant design once and it's changed everything

wicked elbow
#

nah, css isnt hard if you have a designer. its designing on the fly that causes issues.

opaque rivet
#

yes that's so true

#

makes me think whether we should plan projects / make mockups before making them πŸ€”

#

people within the industry do for sure

#

also a big yuck of mine was having to re-write loads of my css to make sites responsive, while these libs often use styling similar to bootstrap to solve that problem

wicked elbow
#

lmao yea, but sense i dont have an eye for design mock ups dont really help πŸ˜†

#

your more likely to get a front-end job with css experience then you are with only bootstrap experience. not to say bootstrap is all bad.

opaque rivet
#

yeah true

#

i can get my head around all the css and know what it does in a practical sense, just hated writing it

glass kindle
#

I have a web-application using Flask. It is searching a kdtree (a datastructure) by loading it once at the top of my code, and then querying the object in every search. Is this the best way? Should I instead load AND query it for every search? Right now, what I'm querying is a global object.

barren moth
#

....

#

I can't see a way to process a plain text data post request in FastAPI

#

is it possible at all?

jagged plume
quiet ridge
#

Hey any web developer there to work with me on a project

subtle frost
outer pier
#

guys have anybody worked with one to one channels in django !!

#

I am trying to do a facebook like notification system in my django app
so whenever something happends say if he has been invited to a group he should be notified as like in facebook . I found the best solution to this problem is using django channels . I integrated django channels with signals so whenever a new database instance is created the django post save signal trigger notification to the group . meanwhile the every user connected to the websocket is now getting the notifications . I dont want that . It should be user specific . Has anybody have any idea to solve this riddle using django channels .

strong torrent
opaque vigil
#

Hello Guys,

I need some help with jQuery and DataTable.

I am trying to set the html attribute - checked to true, based on value that comes from a viewmodel (asp.net core) as a row.

Only the attributes of a switch elements on the first page have the "checked" attribute set to true however. What am I doing wrong?

                data: function data(row) {
                    console.log("row", row);
                    
                    if (row.isActive == true) {
                        $("#customSwitch" + row.id).prop('checked', true);
                    } 
                    else if (row.isActive == false){
                        $("#customSwitch" + row.id).prop('checked', false);
                       
                    }
                    return '<div class="custom-control custom-switch"><input type="checkbox" class="custom-control-input" id="customSwitch' + row.id + '"><label class="custom-control-label" id="customSwitch' + row.id + ' for="customSwitch' + row.id + '"></label></div>'
                   
                     //return '<div class="custom-control custom-switch"><input type="checkbox" class="custom-control-input" id = "customSwitch1"></div>';

                },
            },```
native tide
#

hello I need help with django form M2M field saving

#

can someone help me, can I ask the question here directly?

clear musk
#

Sure

native tide
#

Ok I have a django form and it works fine but when I save it with the M2M field that field is not save correctly

#

but I didn't get any help

#

Maybe its a very specific issue

#

Any ideas

clear musk
#

Sorry, I have no idea...

north summit
#

hey i need help with css i have a div which stores all things in it and i want all things to align center how i do it?

native tide
#

Can you tell me to go about creating a generic form with a M2M Field?

#

How would you do it I have been looking for an answer for so long I am willing to change my existing code

#

because I need a solution

native tide
north summit
#

@native tide can you tell me if i have a <div> then how to make is stay in center

hybrid osprey
#

hello

#

SUP !

versed python
topaz island
#

hi

#

I am new to python how should i learn in a better way

quiet ridge
# topaz island I am new to python how should i learn in a better way

just go and checkout some tutorials like https://www.youtube.com/watch?v=_uQrJ0TkZlc

Python tutorial - Python for beginners
πŸš€ Learn Python programming for a career in machine learning, data science & web development.
πŸ”₯ Want to master Python? Get my Python mastery course: http://bit.ly/35BLHHP
πŸ‘ Subscribe for more Python tutorials like this: https://goo.gl/6PYaGF

πŸ‘‰ Watch the 2020 edition: https://youtu.be/kqtD5dpn9C8

πŸ“• Get My ...

β–Ά Play video
#

I hope this will help

spare iris
lavish prismBOT
#
Resources

The Resources page on our website contains a list of hand-selected learning resources that we regularly recommend to both beginners and experts.

dawn elm
#

crispy forms vs widget tweaks which is easiest to handle css?

rustic pebble
#

Hello, I have the following problem:

I am running Flask with USGI + nginx. I am running 8 processes on UWSGI. I have a endpoint called /stripe/success, it is a webhook endpoint where my payment processor sends a webhook, then there is a coresponding view that determines whether the payment will be captured or released based on stock availability. The problem is that for each request I am retrieving the restock number from the database. Say the restock number is 25 almost always more than 25 users will get charged all processes are not up to date

#

Would doing:

with uwsgi.lock():
  #retrieve restock data here

Work? Would it maybe clip performance by a lot?

halcyon sierra
#

Hi all, I'm trying to solve a problem where I need to webscrape from a site where the login is spread over two pages, i.e. enter username, hit OK, then next page asks for password. I am trying to do this via requests rather than Selenium if possible; wondering what would be required for it to work though. Basically my code so far is the following:

import requests
import lxml.html

url_username = 'https://...'
url_password = https://...

s = requests.Session()

# check for hidden fields (there are none apparently that I've found so I didn't do anything with this info anyway)
login = s.get(url_username)
lxml.html.fromstring(login.text)
login_html = lxml.html.fromstring(login.text)
hidden_inputs = login_html.xpath(r'//form//input[@type="hidden"]')

# post the username to the username page (seems to work; gives a 200 response)
s.post(url_username, data={'username': '<myname>'})

# then I try to navigate to the password page and post the password there (doesn't work; get a 404 response)
s.post(url_password, data={'password': 'abc123'})

How is one supposed to do this properly?

barren moth
#

is there a way to get parallelism in an api request? As of now the server is waiting for the endpoint to finish for one before it does the other

#

I'm using FastAPI

spare iris
#

otherwise don't bc you can get into serious trouble for it

ember bronze
#

Okay: have a large document storage system with millions of documents. Has its own web interface and decent API. Looking for a starting point to build something that sits on top to allow document tagging and automation (e.g. building documents together, scripting proofreading, etc)

spare iris
#

what are you trying to do

#

recruit people?

ember bronze
#

Chat about potential solutions, and ideas

#

Im a former software developer

#

So just looking to tlak about it with someone that is more familiar with the landscape and current technologies

#

Is the market trending towards more custom solutions or open frameworks that can be customized

#

I assume it's the former

#

But, I basically see a lot of these low code/no code solutions making headway in the corporate world

#

So I dunno

#

Power apps seems to have the ability to run python scripts that live in Azure

#

That's close

toxic flame
spare iris
#

yeah i heard that webscraping should be like the last option

#

don't know much tho

toxic flame
#

Or he can alternatively have another api that processes that request. While the other api does the other dirty stuff like requesting..... Webscraping and enterinf logins

#

But since it s a login page every thing can be sent and requested vua web

spare iris
#

idk enough about web dev to comment

#

so i'm gonna be quiet lol

verbal obsidian
#

:)

muted saffron
#

does anyone has a good django guide for starters?

verbal obsidian
#

I'd recommend you the official documentation, it is high quality.

muted saffron
#

aight thanks

toxic flame
#

Totally out of context... But when people say it's a bit faster.... I'm sure they meant from nanoseconds to 1s

verbal obsidian
#

Fasteness in web server usually refer on requests per seconds

#

I'd say a lot, development servers do not focus on being faster or secure

#

none of them scale well

#

and the moment you get a bit of traffic, you'll notice the drop of quality

toxic flame
#

Don't forget about your actual host connection

#

Most of the delay is due to your connection with the ip/website

subtle frost
#

what's the best way to test using nginx locally?

#

would you use a virtual os to practise setting up a server that you can connect to?

wooden lotus
#

need some help on this

verbal obsidian
#

@subtle frost I'd use docker

rich warren
#

agree use docker

pliant bane
#

ok, so i have a flask server, and a small thingi of js code procedurally creates some options in a html <select>

#

but when i request.get.form it, it is none

spare iris
#

yay i'm using flask too

#

for the first time

pliant bane
#

ye, i need to solve this problem thoo

spare iris
#

uh i'm not really sure

noble spoke
#

Youre gonna need to show some code

#

What does small thingi of js code even mean

#

Also if you want form data that should be request.form.get("key")

#

Or request.form["key"]

spare iris
#

he's probably gone by now

north summit
#

hey devs

#

how to make my site goes brrrrrrrrrr

#

i mean how to fix this

my site looks weird in mobile mode```
vestal hound
#

have you heard of adaptive and responsive design

north summit
vestal hound
north summit
#

so every thing is like fiting in one place

wicked elbow
#
[21/Feb/2021 21:29:43] "GET / HTTP/1.0" 400 64015
Invalid HTTP_HOST header: 'fuwu.sogou.com'. You may need to add 'fuwu.sogou.com' to ALLOWE
D_HOSTS.
Invalid HTTP_HOST header: 'fuwu.sogou.com'. You may need to add 'fuwu.sogou.com' to ALLOWE
D_HOSTS.
Bad Request: /http:/fuwu.sogou.com/404/index.html
[22/Feb/2021 00:53:11] "GET http://fuwu.sogou.com/404/index.html HTTP/1.1" 400 64984
Bad Request: /http:/fuwu.sogou.com/404/index.html
[22/Feb/2021 00:53:11] "GET http://fuwu.sogou.com/404/index.html HTTP/1.1" 400 64950
[22/Feb/2021 00:53:18] code 400, message Bad request syntax ('\x05\x01\x00')
[22/Feb/2021 00:53:18] "" 400 -
[22/Feb/2021 02:02:42] "GET / HTTP/1.1" 200 773 // good request
[22/Feb/2021 03:15:34] "GET / HTTP/1.1" 200 773 // good request
[22/Feb/2021 06:44:41] code 400, message Bad HTTP/0.9 request type ('\x03\x00\x00/*Γ \x00\x
00\x00\x00\x00Cookie:')
[22/Feb/2021 06:44:41] "/*Γ Cookie: mstshash=Administr" 400 -
``` anyone know why my server is getting spammed in aws?  doesnt make sense for any other website to be hitting my server. and its not the first time ive seen it
polar trellis
#

probably just bots, scanning through all ip ranges on the internet looking for common vulnerabilities that then can be exploited, wouldn't worry too much about it

wicked elbow
wicked elbow
polar trellis
#

it can be several things causing the error, miss configuration somewhere, bots scanning the site, for me it is too ahard to tell from just this log what exactly is causing this, just try to debug if it is something that is caused by your own techstack or from an external actor like a bot or an external user

wicked elbow
brave nexus
wicked elbow
#

its a search engine i guess

grim cedar
#

has anyone used vercel here ?

gray creek
#

@meager prawn what error specifically?

meager prawn
#

smtplib.SMTPAuthenticationError

meager prawn
gray creek
#

Are you trying to send emails to gmail accounts?

meager prawn
#

yes

#

i am making an web sit

gray creek
meager prawn
#

and using this module to make to send mail when somone enter the data in contact page

meager prawn
#

but nothing happend

gray creek
#

could you send the code?

meager prawn
#

@app.route('/form', methods=['POST']) def form(): first_name= request.form.get('first_name') last_name= request.form.get('last_name') email= request.form.get('email') message = "You have a new entry....!" server = smtplib.SMTP("smtp.gmail.com",587) server.starttls() server.login('GMAIL',"Password") server.sendmail("GMAIL",email,message) server.quit()

gray creek
#

try doing .SMTP_SSL() instead of SMPT, and remove port 587

meager prawn
#

ok

#

let me try

#

smtplib.SMTPNotSupportedError

#

now getting this errror

#

smtplib.SMTPNotSupportedError: STARTTLS extension not supported by server. and this error also

dire violet
#

Hey, looking for a easy way to display csv files as plots on a website? i was thinking about Dash, any other suggestions?

modest mason
#

hey I'm using flask and sqlalchemy to build a rest api, I got a table recipes with id, user_id and name, and a table plans with an id, user_id, date and recipe_id (foreign key).
I'm querying the plans and want to get the recipe name as well as the id, date, recipe_id. I think that's called a left join?

#

I tried with results = db.session.query(Plan, Recipe).join(Recipe).filter_by(user_id=user_id).all()

#

but then I have no clue how to serialise that to json with marshmallow_sqlalchemy

#

and can't find anything relevant in stackoverflow

#

any ideas?

#

that query above ☝️ returns this:

[(<Plan 25801978-48e1-487d-9997-6362272d1dfd>, <Recipe 460e695e-e130-41ce-b68e-8409897c5c9b>), (<Plan 95aaf0e0-926e-4824-91ee-6382da42169e>, <Recipe b2fda62a-4319-443e-8a2c-0fc0d297999d>), (<Plan cb418d37-7497-4dc0-96e3-161fb239d0e5>, <Recipe 158a9f8a-9af8-44ca-91d1-da782510c007>)]

which I don't know how to serialise to json with marshmallow

toxic flame
#

lets see

modest mason
#

ideally I'd like a response like:

"plans": [
        {
            "Plan": {
                "id": ... ,
                "date": ... ,
                "name": "meh",
                "user_id": 4
            }
        },
...

or maybe this, not sure what's the right way

"plans": [
        {
            "Plan": {
                "id": ... ,
                "date": ... ,
                "user_id": 4
            },
            "Recipe": {
                "name": "meh"
            }
        },
toxic flame
#

i think he's trying to turn that query into json format

modest mason
#

assuming my join query is done properly 🀷

#

which I don't know, because I just got objects right now

modest mason
#

ok so assuming my query is valid, I can't get it into json. If I don't say anything about the recipe on my plan schema like

class PlanSchema(SQLAlchemySchema):
    class Meta:
        model = Plan

    id = auto_field()
    user_id = auto_field()
    date = auto_field()
    recipe_id = auto_field()

it just returns and empty json object.
When I try to nest it like this

class PlanSchema(SQLAlchemySchema):
    class Meta:
        model = Plan

    id = auto_field()
    user_id = auto_field()
    date = auto_field()
    recipe_id = auto_field()
    plan = Nested(RecipeSchema)

it just returns recipes, nothing related to the plans

toxic flame
#

Maybe have a function with a prebuilt json format

#

Then pass the queries via a for loop to a function that adds the json to an array

#

for plan, recipe in query:
function(plan, recipie)

modest mason
#

I'd expect marshmallow to do that for me... but I can't figure it out how

toxic flame
#

def function(a, v):
json_format = {
"Plan":a
Blah blah blah
}

array.append(json_format)

#

I am typing on my phone

#

Its pain

modest mason
#

yeap, got it, that should work, cheers. I just expect marshmallow to do it πŸ™‚ Just don't know how. If can't figure it out I'll try that route, cheers

toxic flame
#

oof

modest mason
#

ok I think I got it, the Plan model needed a name db.relationship, or at least that way now it pulls the info without the need of a join, and marshmallow can serialise that info into json

spare iris
#

yay guys i'm gonna make a login page for my app

#

currently watching a tutorial for it

native tide
#

Hi Community. I'm building a website with flask and a mongo DB, for registration I only find tutorials and guides for SQL, do you have any resources for me that I can look at? Appreachiate your help. Cheers. πŸ™‚

native tide
clear musk
#

[u/deleted]

spare iris
#

this doesn't really belong here

#

this isn't about making money

maiden tulip
clear musk
#

oh ur right didn't see that sry

potent geode
#

if im building a flask app should I check if a user is logged in, in the routes or inside of the functions that the routes are using? like if I have /login and it needs to check if the user is already logged in but /login calls a differnt function to handle login stuff which is better practice?

noble spoke
#

You should have a decorator that checks if the user is logged in before letting them access the route

potent geode
#

don't know how to make decorators lol and I don't like using flask forms for the logins

#

ill look into it tho thx

#

also how should my app be structured right now app = Flask(name) is in the same file as my routes

#

should it Be?

#

and things like flask-limiter should they also be in a seperate file?

silver pollen
#

@potent geode you should look into the application factory pattern

potent geode
#

thank you I will research those

grizzled sand
#

Hey everyone, who is using cloudinary cdn with django? I wondering how can i set image extension when upload image. Currently i'm getting image url likecloudinary.com/media/my_image but i want to have cloudinary.com/media/my_image.jpg

toxic flame
#

use pillow

#

just like mine

#

The image url are hosting from the same site using pillow

past cipher
tepid lark
#

how do you structure your django projects?

#

I like to keep my application code in an app/src folder instead of the project root (relative to viewing it in github)

tropic raptor
#

Hello, how to conditionally import a package?

I have a two ways of sending emails - at localhost or by Sendgrid. Developer (using my code) can choose between these and needn't to install, import etc. Sendgrid package if they won't use it

hollow torrent
#

anyone worked with django-allauth?

#

How to have incremental auth for google provider using django-allauth

glad patrol
#

hi

#

i am using sublime text 3 and using flask but these red lines are showing any1 know how to remove these underlines

rich warren
#

@glad patrol are you paying the license ??

native tide
#

my bootstrap collapsible navbar button just doesn't work at all. i checked network, bootstrap JS is loading and its loaded before bootstrap, data targets look good, no clue whats going on. the elements dont even get enabled.

<nav class="navbar navbar-expand-lg navbar-dark bg-darkest">
    <a class="navbar-brand mr-4 text-weight-bold text-secondary" href="{% url 'lance-home' %}">
        <img class='img-fluid mx-3' src="{% static 'lance/lanceconsole.gif' %}" alt="" width="177" height="43">
    </a>
    <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarToggler"
            aria-controls="navbarToggler" aria-expanded="false" aria-label="Toggle navigation">
        <span class="navbar-toggler-icon"></span>
    </button>
    <div class="collapse navbar-collapse text-light" id="navbarToggler">
        <div class="navbar-nav mr-auto">
            <a class="nav-item nav-link mx-1" href="{% url 'lance-home' %}">
                <img alt="" class="icon-white w-25 mx-1" src="{% static 'lance/icons/home-1214326.png' %}">
                home
            </a>
            <a class="nav-item nav-link mx-1" href="https://github.com/xsetrox">
                <img alt="" class="icon-white w-25 mx-1" src="{% static 'lance/icons/github-1288230.png' %}">
                github
            </a>
            <a class="nav-item nav-link mx-1" href="https://www.linkedin.com/in/lance">
                <img alt="" class="icon-white w-25" src="{% static 'lance/icons/linkedin-1239440.png' %}">
                linkedin
            </a>
            <a class="nav-item nav-link mx-1" href="https://instagram.com/lance">
                <img alt="" class="icon-white w-25" src="{% static 'lance/icons/instagram-1239436.png' %}">
                instagram
            </a>
        </div>
        <!-- Navbar Right Side -->
        <div class="navbar-nav">
        </div>
    </div>
</nav>
glad patrol
#

@rich warren nope

native tide
#
Do not provide or request help on projects that may break laws, breach terms of services, be considered malicious or inappropriate. Do not help with ongoing exams. Do not provide or request solutions for graded assignments, although general guidance is okay.
#

i figured it out, apparently i was missing yet another js library even though the bootstrap site says theyre all included in the package i was loading

grizzled sand
#

@past cipher Do you mean in django template or in cloudinary admin settings?

Currently I'm using custom model function which give me url with ext it doesn't have specified. But main problem in DB it still hasn't .ext in url

 def get_cloudinary_img_jpg(self):
       image = self.picture_preview.url
       if image.endswith('.jpg'):
           return self.picture_preview.url
       else:
           return self.picture_preview.url + '.jpg'

faint path
#

is using react with django plausible?

polar trellis
#

most people when using react will use django as a rest api (so django rest framework), if you want to use django and a js framework vue.js seems to be more favorable to use with django, but in the end everything is possible even using react with django

tulip beacon
#

is anyone good at react router please tell me

grizzled sand
#

Found annoying thing Django template method get_next_by_FIELD doesn't sort by published and return all objects. Any way to fix that?

tulip beacon
steady swan
#

do you have a specific question?

tulip beacon
noble spoke
#

what does that mean lmao

#

"how should i render x"

#

can you elaborate

tulip beacon
#

@noble spoke when I press the home icon, I want it to take me to the message sender box in react router

polar haven
#

Can someone guide me through openapi implementation in django

noble spoke
#

something like

import React from "react";
import { BrowserRouter, Switch, Route } from "react-router-dom";
import { MessageBox } from "./wherever";
const App = () => {
  return (
    <BrowserRouter>
      <div className="App">
        <Switch>
          <Route exact path="/home" render={() => <MessageBox />} />
        </Switch>
      </div>
    </BrowserRouter>
  )
}
polar haven
#

Should we suppose to run manage startapp for every model or table

noble spoke
#

thats the sidebar tho, you want it rendered on every page

#

so you should put it outside of the <Switch>

#
<BrowserRouter>
  <div className="App">
    <Sidebar />
    <Switch>
      <Route exact path="/home" render={() => <MessageBox />} />
    </Switch>
  </div>
</BrowserRouter>

like that

past cipher
tulip beacon
# noble spoke ```js <BrowserRouter> <div className="App"> <Sidebar /> <Switch> ...
import React from 'react'
import './Sidebar.css'
import SidebarOption from "./SidebarOption"
import HomeRoundedIcon from '@material-ui/icons/HomeRounded';
import EmojiPeopleRoundedIcon from '@material-ui/icons/EmojiPeopleRounded';
import PeopleRoundedIcon from '@material-ui/icons/PeopleRounded';
import ChatRoundedIcon from '@material-ui/icons/ChatRounded';
import SubscriptionsRoundedIcon from '@material-ui/icons/SubscriptionsRounded';
import NotificationsActiveRoundedIcon from '@material-ui/icons/NotificationsActiveRounded';
import ThumbUpRoundedIcon from '@material-ui/icons/ThumbUpRounded';

function Sidebar() {
    return (
        <div className= "sidebar">
            <img className ="image"
            src="Socio.png" alt=""></img>
            <>
            
            <SidebarOption active Icon={HomeRoundedIcon}text = "Home" /> 
            <SidebarOption Icon={EmojiPeopleRoundedIcon}text = "Surf" /> 
            <SidebarOption Icon={PeopleRoundedIcon}  text = "Friends"/>
            <SidebarOption Icon={ChatRoundedIcon} text = "Chat"/>
            <SidebarOption Icon={SubscriptionsRoundedIcon} text = "Stories"/>
            <SidebarOption Icon={NotificationsActiveRoundedIcon} text = "Notifications"/>
            <SidebarOption Icon={ThumbUpRoundedIcon} text = "Liked Posts"/>
            </>
        </div>
    )
}

export default Sidebar
#

can you show it on the code?

native tide
#

hi um i a having this problem

#

idk what is causing this

#

so can anyone tell what should i do to fix this

#

so i know if there is a problem with my code

noble spoke
native tide
#

anyone?

night sequoia
#

is there anyone here can help me in django?