#web-development

2 messages · Page 154 of 1

nimble epoch
#

you using linux Apache, right?

summer grove
#

linux but nginx

nimble epoch
#

did you try this User=www-data?

summer grove
#

it doesnt change anything setting it to that

nimble epoch
#

i have no other options i searched and i got these. hope you can find it.

summer grove
#

lmao thanks anyways yeah ive been working on this one issue for a while

summer grove
#

does anyone else have experience with sock files and gunicorn?

solar ridge
#

Hey, what package managers are suitable for a Django project on Windows to keep track of JS/CSS libraries? Bootstrap, jquery, etc.

#

Currently my entire python project is managed through virtual environments and git, but of course PIP was not designed for the external HTML'esque libraries.

calm plume
#

If you're okay with learning a syntax that's kinda different from both JavaScript and HTML - Pick React.
If you want to stay with something that's more like normal HTML - Pick Vue.

summer grove
#

@solar ridge I dont usually use package managers I just either download the files to a directory or link to a cdn

calm plume
#

You'll need to have node.js installed, and if you run npm init, it'll autogenerate a package.json that sorta like a Pipfile or a pyproject.toml

calm plume
summer grove
#

@calm plume I may have used it in the past but I've never really had the need to since most of the time the only packages I use is bootstrap and jqueyr

#

jquery

calm plume
#

Ah

#

Well if those are the only two packages, that makes sense

summer grove
#

hey @calm plume do you know anything about setting up django on a production website?

calm plume
#

No, not really. I know Django basics, but I haven't gotten too far into it.

summer grove
#

oh damn

#

setting up the production is a pain in the ass

calm plume
solar fulcrum
#

Hi guys!
Is there a way to grab the text content of any generic webpage, with python (beautifulsoup)?

vestal hound
#

because you can’t run JS

solar fulcrum
#

even using a webdriver like Selenium?

vestal hound
solar ridge
#

Thanks @summer grove & @calm plume

prime ruin
#

Hello, I've got an issue with django and URLs taken from database. I have code as follows:
<a href="https://{{ finding.permalink }}">website</a>
Within finding.permalink there is specific URL for website taken from database. In this example, urls starting with www. like www.google.com will let you go to google website, but when url in database starts with http:// or https://, it will result in incorrect url appearing on the website (http://http://www.youtube.com). I already tried googling this issue, but I'm unable to find anyone with similiar problem. Earlier I have used <a href="{{ finding.permalink }}">website</a>, but that resulted in user being redirected to subpage of my website.
How can I solve this issue?

native tide
#

Hi guys

solar fulcrum
# vestal hound then yes

in that case, how can you identify page text content from all the rest, without using class tags, etc? the purpose is automatic summarization

quick cargo
#

Then use regex to loosely remove all the html tags

#

Probably the easiest method

prime ruin
#

@nova storm Nope

plain iron
#

How can I can change a background colour of website in (HTML)

calm plume
plain iron
#

Will it wil change the colour of the full page

solar fulcrum
radiant storm
#

I use Django and Django Rest Framework to create simple REST applications. I know the basics. But I have no clue what bigger than just simple CRUD applications I can make.

I'm looking for inspiration guys.

#

I have no idea what projects I can make that would keep my motivation to learn alive.

dawn heath
radiant storm
#

I have no motivation and eagerness to study Django and Django Rest Framework documentations when I don't have any bigger projects in mind.

signal bronze
#

should i use flask with react or is it not worth it? I mean i've been trying to set it up and its a pain

calm plume
#

React is great, but idk how it is with Flask

inland oak
#

To work with React

#

Flask is better recomended for beginners in python frameworks though

#

Purely out of leaning experience

signal bronze
#

I like how much control i have with flask vs other frameworks

inland oak
# thorn igloo how though?

They are battery-included frameworks
A lot of stuff is already tuned for you.
Helps to make twice less errors, and having twice better quality

thorn igloo
inland oak
#

Django is good with premade admin site and good ORM for databases, which works great for migrations

#

FastAPI has self generated api wikis out of the box. Which helps to coordinate with front enders easier.

signal bronze
thorn igloo
thorn igloo
signal bronze
#

just all of them

thorn igloo
#

here*

signal bronze
#

i like having my project very clean

thorn igloo
#

but uhm, i think it literally depends on what you add

wooden ruin
topaz finch
#

I am making an object that would take a request object from various web frameworks and standardize it a bit. Many frameworks have a url method to get the full URL of the request. How could I get this from a Django HTTPRequest object as well? Didnt see anything in the docs.

To anyone already typing "why are you doing this, just dont" or anything like it, I am doing it mostly as a fun little project because why not, so please dont go there.

Please @ me when responding.

vital pagoda
#

now this is not a web dev question more of a hosting in heroku question

#

basically i completed a project which is a telegram bot which requests like 300+ websites and returns data to telegram and now id wanna host it in heroku but this server should run 24 x 7
so im not sure which plan to decide upon

void spade
#

Hey so im trying to find a simple django api with sqlite tutorial. Any recommendations?

thorny rover
void spade
opaque rivet
thorny rover
#

so i have an editable, searchable table that auto populates from a csv, how would i make it so if a user edits a cell then clicks the button in the top right, it applies those changes to the csv

surreal portal
#

I'm saying that and my first API under Flask was getting the hand on two basic routes by simply using jsonify and the requests package to handle payloads and responses

#

I meant to ask about Flask-Migrate. Supposing I have a Flask app using SQLAlchemy with a MySQL database, an __init__.py file in which I declare the create_app() factory function, which initializes the database and a Migrate object, does that mean I can use flask db init right after I lauch the app, or do I need a manage.py file?

thorn igloo
prime shuttle
#

i'm trying to add a search bar in my website does anyone know how to do that

calm plume
#

What kind of code does it have?

#

HTML?

prime shuttle
#

rn i just want the search bar to appear and reroute to a blank page or something

#

yea

#

it has html

#

and css for the style

calm plume
#

So you're not asking how to implement search

#

You're asking how to make a search bar?

prime shuttle
#

yea

#

i'm a complete beginner lol

calm plume
#

Then you can just make an <input> element

#

Inside a <form> element

prime shuttle
#

where would I do that?

calm plume
#

On whichever page where you want the search bar

prime shuttle
#

ok thanks

prime shuttle
#

what is Blogpost.objects.filter

#

when I put it in my code it says blogpost undefined

#

i've seen it on a couple of other different videos

terse vapor
#

Flask-admin's view and edit function are usually like this

admin.add_view(ModelView(User, db.session))```
But how can I add like a `@login_required` thing so only user can see it?
pliant birch
#

will i get help in javascript here too?

naive crater
vital pagoda
#

sure

#

something wrong? @daring gale

#

sure

whole sierra
#

can someone thats good at django please help me, I am unable to fix an issue and I have used every fix I can find on stackoverflow etc

#

manage.py migration --run-syncdb (doesnt work)

quick hamlet
#

what hosting service does the python site use?

green snow
#

im making an assigment submission webapp for uni project
i need to copy paste the content of an upload to google and fetch the relevant links and display it on mywebsite
can i do this with beautifulsoup?

inland oak
#

beautifulsoup or xpath for web scrapping works

green snow
#

but how do i sendkeys?

inland oak
#

why would you need sending keys?

green snow
#

like a student uploads a pdf

#

text is extracted from it and it ios compared to documentts submitted by his classmates for plagiarism

#

so i also want the content to beasearched over the internet

inland oak
#

scratching head
I have no idea how this 'pdf uploading' is supposed to work

#

btw, you could check perhaps Google API

green snow
#

its simple

inland oak
#

perhaps it has what you want

green snow
#

ill send a snip

inland oak
green snow
inland oak
#

it can imitate actions of a real user

green snow
#

so we cant do it with bs4?

inland oak
#

nah, bs4 is meant just to extract results

green snow
#

see this is a page from my webapp ,the teacher can view all the submission of students she wil;l get alist of smimlar uploads

inland oak
#

from DOM mess of a resulting page to some format you need

green snow
#

also i want to check the contents of the upload online

#

so i have to use selenium ?

inland oak
#

you can check whatever you wish, if it would be uploaded first at your backend server

green snow
#

ya it is uploaded to the server

#

this is django

inland oak
#

if to your own django, then it can be done just with internal django tools

#

if to not your own site, some foreign service, then possible need for selenium

#

if to some foreign API, all you need a regular request with JSON body inside

green snow
#

no

#

see if u were my teacher

#

and i have to submit to u some case study

#

to check if i have copied from the internet

#

u would copy paste the content of the pdf to google search bar to see if i have stolen it

#

i am trying to do that

inland oak
#

then all you need

#

uploading pdf to your own django web site

#

it can be done without seleium or anything else

#

just use Django available tools

#

and then make request to necessary google url

green snow
inland oak
#

with content you wish to find

#

and then beautiful soup results out of it

#

or actually better connect Google API

#

and make request to it

#

it will return to you JSON results

#

it would be nicer than beautiful soup

#

because you would not be blocked by captchas

green snow
#

i hv very less time in hand

#

i hv selenium experience

#

and bs4 only , but not with any API or django requests

inland oak
#

no need to use Selenium in this situation in my opinion

green snow
#

so with django u can send keys?

inland oak
#

you can possibly use it for that though

#

but it would be overkill

inland oak
#

it will make request without key usage

#

or as I said find Google API

#

and learn how to use it

#

interface to communicate with it, will be the same almost

#

it will return just nicer results, which you don't need to parse with beautiful soup

green snow
#

tysm

green snow
#

will work?

green snow
inland oak
neon vine
#

Hi!

I’m organizing a one day free online workshop for women and am looking for volunteer mentors.

It’s a beginner workshop where attendees follow tutorials and mentors answer their questions, help with the tasks if they are stuck etc. https://djangogirls.org/porto/
A link to register as a mentor: https://forms.gle/b6x2Gzw4F87oJqXi9

obsidian cairn
#
import requests
from bs4 import BeautifulSoup

URL = 'https://www.gamebillet.com/mortal-kombat-11-standard-edition'

headers = {"User-Agent": 'For safety purposes'}

page = requests.get(URL, headers=headers)

soup = BeautifulSoup(page.content, 'html.parser')

title = soup.find(id="productTitle").get_text()
price = soup.find(id="priceblock_ourprice").get_text()
converted_price = price [0:5]

print(converted_price)
print(title.strip())

Can someone help me pls, I want that it checks if the product/game is aviable

ruby flume
#

hi

obsidian cairn
#

hi

ruby flume
near ravine
#

Hi, I'm making a software in Python which makes PDFs into Audiobooks. I wanted to use it for my blind grandpa so that he can read any book he wants to. I need help with 3 things.
`1- I'm using a module called Tika and as you may or may not know, when made into an exe, it requires Java to run. Now I don't want my friends and whoever else installs it to also require Java, I wanna make it look professional. So is there an alternative?
2 - If I use gtts, it does do all languages but the voices suck and pyttx3 sapi5 needs users to install voices and go into the windows registry to change/ add them. I can't exepect others to do the same. So i want to add good tts voices for it.
3 - Deployment: This one's tough. I figured out how to make an exe, but I want it to be a webapp. But making a webapp is tough(have tried) and i need a better quide how to make one.
If anyone can help me with these 3 issues or give advice, you're more than welcome

surreal portal
#

My strategy was extracting text, images, formulas into separate folders but the mining can act differently depending on the pdf version. So if anybody has dug further on pdf structure research I'm interested too

obsidian cairn
surreal portal
near ravine
#

😦

toxic echo
#

in django, do you use a single app with everything or split into multiple apps

inland oak
#

or more like.... one app for one db model that matters

#

ask yourself this... will be those objects different in db model, views, urls, testing, programming logic and etc
if yes, you are definitely needing separating them to different apps

vivid canopy
#

Golang it's good language?

tacit zenith
#

I am trying to host my flask website how do I get it to run on https without the warning of this link might not be secured

valid prairie
#
    def get(self, request):
        if self.request.user.is_authenticated:
            return redirect("/")
        return super().get(self, request)
#

i have following line in FormView

#

can i redirect authenticated user in more convinient way

valid prairie
#

anyone?

native tide
valid prairie
#

im using my own CBV with FormView

native tide
valid prairie
#

okay illtry

topaz finch
#

Flask, and various other frameworks, have a url attribute for request objects. What is the Django equivalent?

native tide
#

How do I add a confirm_password field to my CustomUser model?

#
class CustomUser(AbstractUser):
    pass
frozen wren
native tide
#

It's Django

#

I did py class CustomUser(AbstractUser): confirm_password = models.CharField( max_length=100, blank=False, null=False) But it says this ```You are trying to add a non-nullable field 'confirm_password' to customuser without a default; we can't do that (the database needs something to populate existing rows).
Please select a fix:

  1. Provide a one-off default now (will be set on all existing rows with a null value for this column)
  2. Quit, and let me add a default in models.py
#

Why would a password need a default? Passwords shouldn't be default

thorny rover
#

where would i add an alert to this to show the value of table data

               <script>
                    $(document).ready(function(){
                        $("#sub-jq").click(function(){
                            $('#inv-tab tr').each(function(row, tr){
                                TableData = TableData 
                                    + $(tr).find('td:eq(0)').text() + ' '  // Task No.
                                    + $(tr).find('td:eq(1)').text() + ' '  // Date
                                    + $(tr).find('td:eq(2)').text() + ' '  // Description
                                    + $(tr).find('td:eq(3)').text() + ' '  // Task
                                    + '\n'
                            });
                        });
                    });
                </script>```
frozen wren
plain iron
#

How can I can print an image in a website in HTML

#

If any one can help!

frozen wren
#

It’s <img src=“file location” width=x height=x>

frozen wren
native tide
#

In my models.py file here```py
from django.db import models
from django.contrib.auth.models import AbstractUser

Create your models here.

class CustomUser(AbstractUser):
confirm_password = models.CharField(max_length=100, default='')

class Loan(models.Model):

APPROVED = 'APP'
REGISTERED = 'REG'
EXPIRED = 'EXP'
REQUESTED = 'REQ'
REJECTED = 'REJ'

STATUS_CHOICES = [
    (REGISTERED, 'Registered'),
    (EXPIRED, 'Expired'),
    (REQUESTED, 'Requested'),
    (REJECTED, 'Rejected'),
    (APPROVED, 'Approved'),
]

borrower = models.ForeignKey(
    'CustomUser', on_delete=models.CASCADE, related_name='borrowers')

lender = models.ForeignKey(
    'CustomUser', on_delete=models.CASCADE, related_name='lenders')

date = models.DateField(auto_now_add=True)

status = models.CharField(
    max_length=3,
    choices=STATUS_CHOICES,
    default=REQUESTED
)

def str(self):
return f'#{self.id}'

#

How do I make it impossible for them not to be the same user?

#

Cuz in the api page In the HTML form I can set them to be the same. I don't want that.

#

It shouldn't be possible

frozen wren
native tide
#

yeh

frozen wren
#

Ahh nice.

indigo kettle
#

@native tide you need to set unique_together

native tide
#

where?

indigo kettle
#
class Loan:
  class Meta:
    unique_together = ['lender', 'borrower']
#

this will set the constraint at the DB level

native tide
#

i am making a website and i want an image as a background but when i open the live server it is not appearing

native tide
green snow
#

can any1 tell how i can fetch the href tag

native tide
#

@indigo kettle can u help

#

?

native tide
green snow
#

ya

native tide
green snow
#

theres a link in it not #

native tide
#

and then vs code will suggest u

#

then enter

green snow
#

didnt work

native tide
green snow
#

like i want the link that belongs to that dv tag

native tide
#

i wrote that # for my code

#

bruh

#

it will be empty

#

if u type a

#

then enter

#

@green snow

green snow
#

m stuck since morning,i just want a script that returns top 5 links of a google search

#

m getting none

native tide
#

then type a then enter

green snow
#

yaa ok

native tide
#

on vs code

green snow
#

gimme 2 mins

native tide
#

ok

green snow
#

idk how to cal

#

@native tide

dawn heath
native tide
#

bruh

green snow
#

i sent u dm

cosmic timber
#

Actually pretty newb question. Is there any way to sort IntegerField in template?
Like, i have a bunch of numbers 20, 38, 14, 43 in db. And wish to render it in template by decrease => 43, 38, 20, 14
Django could do that with any filter or i have to filter it with python before render in views?

#

Lol, nvm, i could use order_by in query. Sry for stupidness. =|

terse vapor
#

In flask stringfield, when i try to input a name or a number, there's always a few recommendation for me to input, is there any way to block it?

crude glade
terse vapor
#

ok ok

crude glade
#

there might also be some css to do something similar

#

and if you're using chrome, it tends to ignore passwords so you can try
autocomplete="new-password"
instead

terse vapor
#

It worked! 😃

pure gull
#

how possible is it to be learning two languages at the same time (php and python)

#

or should I really focus just on one

crude glade
crude glade
tired wadi
#

lmao flask is so spoiled

#

DoEsNt WoRk In SeCoNdArY ThReAdS

#

lol

native tide
#

Here in my component https://pastebin.com/rUb2ica9
I want to get data from a backend api
django rest api
And If you look in the renderBorrower method, I try to return this ${borrower.first_name} ${borrower.last_name}
But It gives me this errror: loansList.jsx:20 Uncaught TypeError: Cannot read property 'first_name' of undefined at LoansList.renderBorrower (loansList.jsx:20) at loansList.jsx:63 at Array.map (<anonymous>) at LoansList.render (loansList.jsx:55) at finishClassComponent (react-dom.development.js:17485) at updateClassComponent (react-dom.development.js:17435) at beginWork (react-dom.development.js:19073) at HTMLUnknownElement.callCallback (react-dom.development.js:3945) at Object.invokeGuardedCallbackDev (react-dom.development.js:3994) at invokeGuardedCallback (react-dom.development.js:4056) at beginWork$1 (react-dom.development.js:23964) at performUnitOfWork (react-dom.development.js:22776) at workLoopSync (react-dom.development.js:22707) at renderRootSync (react-dom.development.js:22670) at performSyncWorkOnRoot (react-dom.development.js:22293) at react-dom.development.js:11327 at unstable_runWithPriority (scheduler.development.js:468) at runWithPriority$1 (react-dom.development.js:11276) at flushSyncCallbackQueueImpl (react-dom.development.js:11322) at flushSyncCallbackQueue (react-dom.development.js:11309) at scheduleUpdateOnFiber (react-dom.development.js:21893) at Object.enqueueSetState (react-dom.development.js:12467) at LoansList.push../node_modules/react/cjs/react.development.js.Component.setState (react.development.js:365) at loansList.jsx:10
And the weird thing is....
When I spam the refresh button It works sometimes
And sometimes gives me an error

opaque rivet
#

when you're spamming the refresh button, you're just hoping that your component made an API call before you refresh.

native tide
#

so do I put the function in componentDidMount?

opaque rivet
#

to fix this just add a conditional to your JSX, like:

{this.state.loans && this.state.loans.map(...)}
#

but note that this.state.loans has to be a falsy value at first, (you have an empty array - I don't know if that's falsy (I think it is) but let me know)

opaque rivet
#

so your state will be empty.

native tide
#

By any chance, do you know how to make a loading screen?

#

before everything renders?

opaque rivet
native tide
#

that simple?

opaque rivet
#

well yeah, you just have to handle the loading state and making the component (or importing it from some comp. library)

#

all sorted now?

native tide
#

no

#

it still gives me an error

opaque rivet
#

show us the code

native tide
#
<tbody>
          {this.state.loans &&
            this.state.loans.map((loan, id) => {
              const { id: pk, borrower, lender, amount, status, date } = loan;
              return (
                <tr key={id}>
                  <td>
                    <b>#579{pk}A</b>
                  </td>
                  <td>{this.renderBorrower(borrower)}</td>
                  <td>{lender}</td>
                  <td>${amount}</td>
                  <td>{this.renderStatus(status)}</td>
                  <td>
                    <i className="far fa-calendar"></i> {date}
                  </td>
                </tr>
              );
            })}
        </tbody>```
opaque rivet
#

and what's the error

native tide
native tide
#

can't read property first_name of undefinded

opaque rivet
#

in renderBorrower(id) print your state.users

#

this.state.users.find((user) => user.id === id); is not returning anything

native tide
#

okay now

#

the whole thing is successfully rendered as it should...

#

I also printed the users as you can see

#

but lets refresh the page

#

Now this

opaque rivet
drifting furnace
#

It is?

opaque rivet
#

so put your initial state as null

#

apparently so

drifting furnace
#

!e print(bool([]))

lavish prismBOT
#

@drifting furnace :white_check_mark: Your eval job has completed with return code 0.

False
drifting furnace
#

Hmm it doesn't seem so this

opaque rivet
drifting furnace
#

Oh yeah I remembered

opaque rivet
#

that's python, this is JS

drifting furnace
#

You need to check if it's equal to [] to check if it's empty, not just boolean it

native tide
#

Im confused

opaque rivet
#

then your state will be mapped through only once the state is available

#

because apparently [] is truthy

native tide
#

Same sort of error

#

but this time it's null instead of undefined

#

hi

#

if you go here

#

it takes you to a directory thing

#

i use infinityfree for hosting

#

how do i fix it

opaque rivet
#

oh I see

#
{this.state.loans &&
            this.state.loans.map((loan, id) => {
              const { id: pk, borrower, lender, amount, status, date } = loan;
              return (
                <tr key={id}>
                  <td>
                    <b>#579{pk}A</b>
                  </td>
                  <td>{this.renderBorrower(borrower)}</td>
                  <td>{lender}</td>
                  <td>${amount}</td>
                  <td>{this.renderStatus(status)}</td>
                  <td>
                    <i className="far fa-calendar"></i> {date}
                  </td>
                </tr>
              );
            })}
#

wrap the code on the right side of the conditional in parenthesis ()

native tide
#

this you mean? jsx {this.state.loans && (this.state.loans.map((loan, id) => { const { id: pk, borrower, lender, amount, status, date } = loan; return ( <tr key={id}> <td> <b>#579{pk}A</b> </td> <td>{this.renderBorrower(borrower)}</td> <td>{lender}</td> <td>${amount}</td> <td>{this.renderStatus(status)}</td> <td> <i className="far fa-calendar"></i> {date} </td> </tr> ); }))}

#

Still doesn't work.

native tide
opaque rivet
#

and if it's not that then I don't know what the issue is

native tide
#

how do i remove the directory thing

toxic echo
#

is there any way to link css files from a child template in django

#

sorry i dont know if child if the term
i have base.html with base.css linked in the <head> tag
i extend base.html from home.html and i want to link home.css in the same <head> tag

silver moss
#

Src

#

Link by using address of css

native tide
#

new solution..

#

just telling people

#

to go to /zeta/

#

lmao

#

oh well im too dumb to fix it

native tide
jovial mist
#

Is it ok to store sensitive info in the session?

opaque rivet
jovial mist
opaque rivet
#

what sensitive info are we talking about?

jovial mist
#

The user's token

opaque rivet
#

yeah that's fine

jovial mist
#

Ok thanks

pure gull
prime shuttle
#

does anyone know why this error shows I turned on allow all cookies on chrome

#

but it still shows the same message

toxic echo
native tide
#

@toxic echo You can make a block called css and then link on every page you need another css add it there and the one from the base for example gets overriden

toxic echo
prime shuttle
#

nvm

#

figured it out

wooden ruin
#

how can I choose specific permissions per method on a modelviewset?

#

this is my PostViewSet create() method

#
    def create(self, request):
        permission_classes = [permissions.IsAuthenticated]
        try:
            user = User.objects.get(username=request.data["author"]["username"])
        except user.DoesNotExist:
            return Response({"message": "user with username does not exist"})
        post = Post(
            body = request.data["body"],
            author = user,
            likes = 0
        ).save()
        return Response({"message": "Your post has been saved"})
#

however i can still send post requests even if i'm not authenticated

#

i want to the user to only be authenticated on posts requests, but get requests should not need auth

vestal hound
wooden ruin
violet briar
#

how do I inherit from multiple classes/prototypes in JS, kinda like multi class inheritance in python, what's the syntax for it, I am thinking about something like this:

class someClass extends (Parent1, Parent2) {...}
native tide
#

Does anyone know how to return JSON errors when there is an authentication error on Flask?
It's returning HTML and my JSON client is breaking

vestal hound
#

(basically)

#

you can implement multiple interfaces though

violet briar
vestal hound
violet briar
#

because I want to create a child class that inherits methods from 2 parent classes

vestal hound
#

but what I'm asking is

#

why aren't you using a pattern more appropriate for JS

#

for example...composition?

calm plume
#

JavaScript isn't isn't a class based object oriented language.

violet briar
#

what is composition?

vestal hound
calm plume
vestal hound
#

honestly, prototypical inheritance is weird for most people though

#

it's interesting, but

calm plume
#

But it's not the way here

violet briar
#

I mean, yes, classes in js are just a syntactical sugar wrap around prototypes

#

it's like giving needles to drug addicts

native tide
#

Does anyone know how to return JSON errors when there is an authentication error on Flask?
It's returning HTML and my JSON client is breaking

#

Flask RESTFUL btw

violet briar
#

hey, uhm, how do I implement something to python's __iter__ and __next__ methods in a javascript class to make it support iteration?

violet briar
#

ok thanks

humble vortex
#

Hi guys, I need help with a project.
I've not time to work with and it needs to be updated.
https://github.com/joke2k/django-environ

If somebody is interested to help, please write me.

GitHub

Django-environ allows you to utilize 12factor inspired environment variables to configure your Django application. - joke2k/django-environ

stark quartz
#

Hey can anybody help me to understand how can we turn website to a company

native tide
#

Make it an NFt and sell for $1billion, the end.

stark quartz
#

Seriously pls like elon musk zip2 and x.com

echo valve
#

Collection:

[{
  "_id": 1,
  "ImageUrl": "http://domain.com/image.jpg",
  "Age": 28,
  "Gender": "M",
  "Hour": 3,
  "CollectionID": "testcollection1,testcollection2",
  "Date": {
    "$date": "2021-05-04T00:00:00Z"
  },
  "MatchedTimeStamp": "2021-05-04 15:01:44.006",
  "FaceCode": []
}]

Code:

from pymongo import MongoClient
client = MongoClient('localhost')
db = client.database
collection = db.collection
collection.find_one()

Output:

$ b'{null}'
#

pymongo collection.find_one returns null

#

how to solve this issue

#

?

native tide
#

What is better for web development:Python or Typescript?

inland oak
native tide
#

ok

short ingot
#

I am getting error R15 and R14 while deplying a flask web app using Heroku. The app has Sklearn, Pandas and Flask as imports, so i suspect I have exceeded the maximum memory offered by the Heroku free plan. How do I go about it now as the plans dont metion storage. PS: its a ML app

grand sage
#

Anyone who have some information how I can get users to login with discord on my website?

random spindle
#

hello what is the best ressource to learn web dev in python

grand flicker
#

Can anyone suggest some good Django tutorials?

calm plume
#

Under the documentation tab of their website, there's a section for the tutorial

grand flicker
flint sky
#

Hey can anyone help me on how to disable those HTML pop up validators.

#

I am actually using bootstrap classes on the flask validators and don't want those additional validations.

thorn igloo
#

but in essence, you basically need to add the novalidate attribute to the form

violet briar
#

does javascript have keyword arguments like python?

mint folio
nimble epoch
distant charm
#

Hello people

#

my css file is not working with my react app no idea why

#

trying to style bootstrap component

calm plume
#

Can you share the code?

#

And how you imported the css file?

distant charm
distant charm
calm plume
#

Can you share the relevant parts of the css file?

distant charm
#

it consists of these 10lines only```css
.card{
width:50%;
float: none;
margin-bottom: 10px;
margin-top:50px;
}

@media (max-width:991px){
.card{width:50%}
}```

calm plume
#

Can you try sticking a background color on .card? Just to see if it applies?

distant charm
#

Thank you so much for your time

calm plume
#

Good luck with your app!

buoyant shuttle
#

ok guys what does this mean>

pure thistle
#

I am using reactjs and Django Rest Framework so, whenever I make a request to the api using fetch or axios it shows data on the browser’s network section and I don’t want that data to be shown how can I approach this problem

slow heron
#

I want my website to have somethign like a chat option, but what is the best way to update the chat

#

Should I use react or is there an easier way with flask

foggy bramble
#

hello everyone.
I need to compare datetime field to datetime now, if the difference is equal to 10 minutes i need to send email.. Best way to do it?

foggy bramble
native tide
#

time delta

#

search for "delta"

buoyant shuttle
#

but i solved it

foggy bramble
balmy crane
#

Is anyone here good with requests?

jade lark
glossy arrow
#

Hey guys

#

is there a specification for ASGI middlewares?

balmy crane
#

i'm trying to get access to a page, but it has a js loading screen

#

meaning that when i try to request the site

#

it returns the info about the loading screen not the actual site

#

heres my code

#

url = requests.get("https://robertsspaceindustries.com/spectrum/community/SC/forum/4/thread/weekend-playtest-fleet-week-expo-halls-javelin-tou/4006567")
soup = BeautifulSoup(url.text, 'lxml')
print(soup.prettify())
#

theres the link

#

you can see it has a loading screen

jade lark
#

you'll need to intercept requests. If you don't know how to do that then you'll need to use puppeteer or selenium. The site might have security for it though.

#

I own a service for this specific case if you'd like I can send it to you. Can do up to 1000 requests for free and it does render JS as well.

#

Looking at the site the whole thing uses React.

balmy crane
#

Is it impossible to web scrape then?

jade lark
#

No, just harder.

#

You can use puppeteer or selenium.

balmy crane
#

How does your service work

jade lark
balmy crane
#

And is there a good tut for puppeterr/selenium

jade lark
#

Try this first

#

If there is security in place then it will be harder

balmy crane
#

OKay so just download theses?

#

are they packages?

#

I looked up some answers

#
from bs4 import BeautifulSoup
from selenium import webdriver
driver = webdriver.Chrome()
url = "https://shop.nordstrom.com/c/womens-dresses-shop?origin=topnav&cm_sp=Top%20Navigation-_-Women-_-Dresses&offset=11&page=3&top=72"
driver.get(url)
soup = BeautifulSoup(driver.page_source, 'html.parser')
driver.quit()
print(soup.prettify())
#

this is what i got from stack overflow

#

but when i try this, it tells me i dont have the chromedriver directory

jade lark
#

You'll need to download the webdriver

balmy crane
#

sorry im pretty slow haha

#

i downloaded chromedriver.exe

#

how do i put it in my path?

jade lark
#

alright good

balmy crane
#

Starting ChromeDriver 90.0.4430.24 (4c6d850f087da467d926e8eddb76550aed655991-refs/branch-heads/4430@{#429}) on port 9515 Only local connections are allowed. Please see https://chromedriver.chromium.org/security-considerations for suggestions on keeping ChromeDriver safe. ChromeDriver was started successfully.

#

this is my cmd rn

jade lark
#

Did you figure out how to put it in your path?

#

you don't run it

#

put it into
C:\Windows\System32

#

drag and drop it onto there

#

then try and run your program

balmy crane
#

okay so it ran

#

and like a window opened up of the

#

website

#

but it still got info of the loading screen

jade lark
#

well yeah that will happen

#

cause the loading screen takes a bit

#

so

#

from time import sleep

#

sleep(5)

#

or something

balmy crane
#

sleep 5 where though

#
driver = webdriver.Chrome()
url = "https://robertsspaceindustries.com/spectrum/community/SC/forum/4/thread/weekend-playtest-fleet-week-expo-halls-javelin-tou/4006567"
driver.get(url)
soup = BeautifulSoup(driver.page_source, 'html.parser')
driver.quit()
print(soup.prettify())
jade lark
#

You should wait for an element but that might be beyond your scope atm

#

and after the driver.get

balmy crane
#

holy shit

#

it worked

#

wait

#

by wait for an elemen

#

you mean like wait for a specfic class to appear or something?

#

thank you so much bro

jade lark
#

Yeah exactly that

#

and no problem

balmy crane
#

Okay, i prop would need a bit more knowledge about how this driver stuff works

#

but would it kinda be like (sudo code)

#

While True: Try: Get Class then quit driver Except: pass

#

or something

jade lark
#

Nah it would be a method you call and it blocks the program until it either gets a response or timeouts.

#

Look at some tutorials or the docs for selenium

balmy crane
#

okay will do

#

thank you bro

#

have a good day

jade lark
#

You too!

prime shuttle
#

views.py

def search(request):
    context_dict = {}
    query = request.GET.get('q')
    if query:
        results = Sklep.objects.filter(miasto=query)
        if results.count():
            context_dict['results'] = results
        else:
            context_dict['no_results'] = query
    return render(request, "index.html", context_dict)

template.html

 <form class = "d-flex " method = POST action ="{% url 'search_venues' %}">
    {% csrf_token %}
    <div class = sbar>
      <input class="form-control me-2" type="search" placeholder="Search" aria-label="Search" name="searched">
      <button class="btn btn-outline-success" type="submit">Search</button>
    </div>

models.py

class Sklep:
    miasto = models.CharField(
        max_length=200,
    )
    nazwa = models.CharField(
        max_length=200,
    )
    adres = models.CharField(
        max_length=200,
    )
    def __str__(self):
        return self.miasto +", "+ self.nazwa+ ", "+ self.adres
#

so currently my search bar looks like this

#

any idea on how to make it look more appealing perhaps a larger search bar
with the search button connected to the bar
and a different colour

wooden ruin
#

what's a best practice when dealing with json web tokens in the frontend? so far i'm just storing it in a vuex store, and just using it whenever i need an authorized request - not too sure if this is the safest thing to do

#

using drf-simplejwt with channels btw

follow-up question: how can I specify jwt permissions per function-based views, as opposed to viewsets?

terse vapor
#

Just a simple question, why is my jwt token always doesn't work😅

green snow
#

how do i extract the website name,here: 'wikisource' using re

sacred forge
#
from flask import Flask, request, render_template_string

app = Flask(__name__)

@app.route('/', methods=['GET', 'POST'])
def index():
    if request.method == 'POST':

        print('--- original order ---')

        for key, val in request.form.items():
            if key.startswith("item"):
                print(key, val)

        print('--- sorted ---')

        keys = request.form.keys()
        keys = [key for key in keys if key.startswith("item")]
        keys = sorted(keys)

        for key in keys:
            #print(key, request.form[key])
            print(key, request.form.get(key))

    return render_template_string('''
    <html>
    <head>
         <title>KrkanoidBot</title>
    </head>
    <body>
         <h1>Testiranje</h1>
         <h2>Testiranje</h2>
    </body>
    </html>
''')

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

Can I add css file to my Python Flask file ?

sacred forge
dusk portal
#

hey anyone's up??

native tide
#

yeah

dusk portal
native tide
#

Sure ? I dont know how much ill be able to help

dusk portal
#

u know flask??

#

@native tide

native tide
#

Nope

dusk portal
#

then np

#

other wil help

#

np

native tide
#

How does one submit html forms

#

anyone experienced with payment gateways?

#

how to add in a site a payment gateway and what to focus on?

inland oak
native tide
#

yes exactly! Also working with flask

inland oak
#

going to research how it works on a next week probably, or week after that

#

its testing example looks working pretty easy

#

you can create special testing account there

#

and making testing payment as much as you want

#

in order to get grasp of that thing

native tide
#

I think motsly the integration is the most work, other than that the transaction are all on the gateway.

inland oak
#

mm there are two mods as far as I know

#

first one... you are using their system of things to buy, and basically you put everything on their shoulders

native tide
#

exactly

inland oak
#

in second approach you can create your own database with things to buy, and client system

#

and you just wire payments to their system

native tide
#

for every test though, the fees will go wild right?

inland oak
#

perhaps some limit per month or something

native tide
#

this requires to make an arrangement with Stripe the company as well?like a subscription?

inland oak
#

they give testing account/token access by default

native tide
#

nice

inland oak
#

there is also public key though, probably it is allowed for exposing

native tide
#

If I want to keep fees for myself for every transaction, this is complex?

inland oak
native tide
#

i mean additional fees from what Stripe will take.

inland oak
#

some fee would be probably for sure

native tide
#

like an app where people transfer money to other people and using Stripe gateway I also keep a small amount as the site owner.

inland oak
#

how much would you succeed to transfer money between two random people, is another problem though

#

it needs finding some solution

native tide
#

what are the problems?

inland oak
#

the problem to find a way to transfer money between two random users

#

I get it, that's what you wish to do

native tide
#

via a gateway?:)

inland oak
#

Stripe in the first place a way to collect money from users to site owner

native tide
#

it isn't about two separate bank accounts?

#

hmm

#

What can I use then for that purpose?

vagrant owl
#

Hi guys, need help.
Let's say I have a simple flask API and backend where I have some files in access and send data to the front-end from. I wanna have a functionality where if let's say i make a post request and change the data in the files, it gets updated in a lookup table and then after a couple of seconds, the front end gets updated. Any idea where I can get such an implementation?

slender skiff
#

Does anyone know anything about express routing. I'm having a very basic express routing issue

terse vapor
worldly furnace
#

When you program python, where do you program it is there a good app to use. besides pycharm?

violet briar
#

should I use px or should I use em / rem in CSS?

#

which one is better in terms of compatibility with different view ports on different devices?

vestal hound
#

because you generally want your UI to scale with the font size your user has set

violet briar
#

I mean, if the user wants to zoom they'll use their browser's zoom feature, no one zooms by zooming font

opaque rivet
#

Using px is just hard-coding your design, it'll harm the responsiveness of your site. Use rem.

vestal hound
#

but they exist

#

and also

#

I personally find it easier to keep my design uniform

#

when everything is defined in terms of rem

#

so I went to do a bit of research because I was wondering about the browser zoom point

#

Long live the modern browser! Browsers are getting better these days. We seem to be in a golden age where there’s a never-ending stream of new features added for the benefit of the users accessing the page, and really great tools for those creating the page. It hasn’t always been the case, though. Earlier versions …

#

this is good I think

terse vapor
#

How can I use redirect(url_for()) this flask route with token?

@app.route('/protected?token=<token>', methods=['POST', 'GET'])
def protected(token):```
vagrant owl
inland oak
#

user friendly and nice

#

some people debate only if you should use VS code or pycharm ;b

#

or at least I saw a joke recently, that we should rename #editors-ides into #vscode-vs-pycharm

dusk portal
#

hey

dusk portal
#
C:\essentials\python\python.exe: can't open file 'C:\Users\91834\PycharmProjects\website\manage.py': [Errno 2] No such file or directory```
#

im new to django

jade lark
#

There isn't a manage.py file in the directory you're running from @dusk portal

pale mulch
#

Hello, I'm a PHP Developer and learned Python, so I want to use this in Web, so can anyone please recommend me a Flask or Django course?

calm plume
native tide
#

Hello

#

I need to get the text from an image url, cv2.imread but with an image url, i don't want to download the image

pastel relic
#

Hey! does anyone have any experience with selenium?

jade lark
jade lark
native tide
#

I have tried that, but I don't know how to make it read the image.

jade lark
#

If that's not supported make a custom decorator or function.

jade lark
native tide
#

Okay thx

languid raptor
wet dust
#

I picked up flask and I don’t want to learn django after learning flask

languid raptor
#

Django is the batteries included version of flask

wet dust
#

Because flask is doable for me

calm plume
#

Flask doesn't have a database abstraction layer or anything like that

jade lark
#

Django also does have a larger amount of packages that are maintained. It includes security, admin dashboard, migrations, orm, auth, emailing, and much much more.

#

Meaning you don't have to worry about as many small details. For example Instagram, Pinterest, NASA, quite a few more all run on some form of Django.

#

Just allows you to iterate and ship things fast.

wet dust
#

Hm - so should I forget flask and learn Django? Or is flask doable

#

Like is it fine or is flask bad

jade lark
#

Flask is fine.

wet dust
#

Alright great

jade lark
#

Flask is perfectly fine.

#

I started with Flask first myself and then moved into Django. As Flask does give you a different perspective of how things work.

wet dust
#

On youtube

pale mulch
#

Ok, thanks everyone

jade lark
#

In this Python Flask Tutorial, we will be learning how to get started using the Flask framework. We will install the necessary packages and get a basic Hello World Application running in our browser. Let's get started...

The code for this series can be found at:
https://github.com/CoreyMSchafer/code_snippets/tree/master/Python/Flask_Blog

Djang...

▶ Play video
languid raptor
#

@jade lark Speaking of packages--I'm having a time understanding django-wiki project. It's a module, so when you install it, you have a django project with settings and little else. What's the quick take on customizing a package like django-wiki (I want to add django-tagulous) when the whole project is inside a module?

jade lark
languid raptor
#

@jade lark Ok. classes in what files? Do I create a new app for django-wiki and then add override classes there?

#

call it django-wiki-overrider

wet dust
#

What are you trying to do? Like specifically

jade lark
#

Nah don't do that

#

Create it where your application requires it.

#

If you're using it throughout multiple apps then created a utils module, then a file and class for it in there.

languid raptor
#

that's the whole application. just a wiki page. Django-wiki has everything I want except for tags

jade lark
#

Break it down further.

#

Does the wiki have authors, tags, posts?

languid raptor
#

its on github

jade lark
#

I know that

#

I mean for your application

languid raptor
#

duh. type fast. think slow

#

its for knowledge management for the office. <10 users.

#

but django-wiki doesn't support tagging. And I want to have an ontology of items for search. in other words, tags like SE

jade lark
#

Right perfect

#

so you would just make a tags app

native tide
#

hey, does someone here know a bit about javascript and wtforms?

languid raptor
#

Ok. My mental map ... make tags app and in there put the override classes for django wiki

jade lark
#

so structure would be like

custom_app
  - tags
    - views
    - models
    - templates
  - settings.py
  - etc...
#

in settings.py you would include the django-wiki app from pip

Then if you're creating custom views for parts of django-wiki you would make apps and override them as required. For example, if they had an articles app. You would make one yourself and override it there. This will allow the code base to be much smaller and separated.

native tide
#

do you know something about flaskwtf and javascript @jade lark ?

jade lark
native tide
#

i have a flaskwtf form in a bootstrap modal, but whenever i submit the form the modal also gets closed even when there is an error in the form

silver tinsel
#

Hey, can someone help me with flask?
i just followed a basic tutorial on how to plot a chart on a webiste and i have the exact same code now but i get an error when trying to load the website

#

thats my error and i guess you wanna see the code too 😄

native tide
#

i tried to find a solution but the javascript isnt working

silver tinsel
#
from flask import Flask, render_template

app = Flask(__name__)


@app.route("/")
def home():
    data = [
        ("1-01-2020", 1234),
        ("2-01-2020", 1140),
        ("3-01-2020", 1050),
        ("4-01-2020", 934),
        ("5-01-2020", 834),
        ("6-01-2020", 734),
    ]

    labels = [row[0] for row in data]
    values = [row[1] for row in data]

    return render_template("graph.html", labels=labels, values=values)
wet dust
#

dropdowns ig? not sure

silver tinsel
#

and i have everythin the same as in the tutorial and now i have no idea why i get the error :/

#

would be awesome if someone could take a look at it🙈

jade lark
wet dust
#

dropdowns are basically like choose from a list

#

like it's a dropdown with January, February, etc.

wet dust
#

tbh*

#

well if they type something invalid you'll need to check for it

#

I'd suggest drop downs

#

for the months

jade lark
wet dust
#

as for the year and day -- just use a regular string field

#

Well I haven't worked with dropdowns but with string fields

silver tinsel
#

i do that

jade lark
jade lark
# silver tinsel i do that

When requesting the page does the console show you an error of what happened? If not you need to turn on debug mode.

silver tinsel
#

thats all it shows

jade lark
#

That's not debug mode

#

and your console for python

silver tinsel
#

thats what the python console shows

jade lark
#

So the template wasnt found

silver tinsel
#

yup

jade lark
#

Theres your problem then

silver tinsel
#

and how do i solve this🙈🙈

jade lark
#

Fix the path

silver tinsel
#

i am pretty sure the path is correct

#

or which path do you mean

jade lark
inland oak
#

is it in folder 'templates'?

silver tinsel
inland oak
#

if not, it is probably in the wrong path

jade lark
#

It's not due to the script tag man

#

it's due to the location of the html file

native tide
languid raptor
jade lark
native tide
silver tinsel
silver tinsel
#

but as they are in the same directoy the pathing should be correct like this or not?🙈

native tide
jade lark
jade lark
jade lark
native tide
silver tinsel
#

so i have to put graph.html in the templates directory

#

ah well one error is gone now xD

jade lark
silver tinsel
#

but now i get this :7

short ingot
#

whats the difference between the Premium Intel with NVMe SSD NEW and Regular Intel with SSD in the digital ocean server plans?

jade lark
# silver tinsel

Couldn't find the element. Try moving the script tags to the bottom of the HTML file (if they're not already there). Right before </body>

jade lark
silver tinsel
#

oh damn i am dumb i misspelled it damn

jade lark
silver tinsel
#

ahh now it works 🙂 thanks for your time✌️

wet dust
#

nvm

#

u fixed it

silver tinsel
#

i fixed it yea 😄

#

thanks tho

native tide
short ingot
#

thats the difference

jade lark
#

Unless you're going with dedicated.

short ingot
#

this is a VPS

inland oak
#

if just for developing

jade lark
#

That's a droplet lad

inland oak
#

any SSD is enough

#

is it your just testing ground, right?

jade lark
#

so it's a VPS yes, but it's not dedicated

short ingot
#

its my hobby project

jade lark
#

go with the normal droplet then

inland oak
#

more than enough having the cheapest

short ingot
#

ok cool thanks

inland oak
#

I rent for 3,5$ the same thing

short ingot
#

where do you do that?

inland oak
#

as long as it is SSD, and 25gb and 1 ram

#

it is good

jade lark
short ingot
inland oak
#

yeah, it is in my native country, I think it does not exist in English

short ingot
#

ohh

native tide
inland oak
#

but they asked from me

#

to pay for 1 year in advance%

#

not really good I thought

languid raptor
#

Does anyone have any recommendations for tutorials or authors who describe/explain Django override of views and models?

inland oak
#

I learned it from official documentation I think

#

in their tutorial

#

at the end of the chapter

#

it explains about templates

#

but I guess everything else should be sort of same

#

or may be you are looking just for override through inheritance perhaps

jade lark
#

Couple of things:

  1. Remove the action from the form
  2. Specify ID's for all values of your input fields, that and names
  3. You can try specifying a submit event instead of the click event for a button and try that instead
languid raptor
#

@inland oak I will look at that. I've just been looking at Django docs for reference and didn't get into the tutorial. I completed william vincent's override tutorial for admin. I hoped to find more on the web but its tough search

opaque rivet
#

Do you guys understand CSRF and the role of the csrftoken cookie?

inland oak
#

then highly likely you already learned that

languid raptor
#

@inland oak just trying to grokk it better

#

from 10,000 feet

languid raptor
opaque rivet
#

well - yeah. I plan on adding it for my JS forms but I'm a bit hazy on its implementation. Gonna give it an extra read tonight.

#

doing stuff for the sake of it, without actually understanding what I'm doing, just hurts me in the long-run

languid raptor
native tide
void spade
#

Hey so im trying to get some test done on my django rest framework and it doesnt seem to work on some of my tests

#

class GatherTestCase(APITestCase):

    def test_gather(self):
        response = self.client.get("/api/contacts/")
        self.assertEqual(response.status_code, status.HTTP_200_OK)

class CreationTestCase(APITestCase):

    def test_creation(self):
        data = {"name": "test name", "email": "test@test.com", "phone_number": "+00000000000"}
        response = self.client.post("/api/contacts/", data)
        self.assertEqual(response.status_code, status.HTTP_201_CREATED)

class UpdationTestCase(APITestCase):

    def test_updation(self):
        data = {"name": "test name", "email": "test@test.com", "phone_number": "+00000000000"}
        response = self.client.patch("/api/contacts/1/", data)
        self.assertEqual(response.status_code, status.HTTP_200_OK)

class DeletionTestCase(APITestCase):

    def test_deletion(self):
        response = self.client.delete("/api/contacts/1/")
        self.assertEqual(response.status_code, status.HTTP_204_NO_CONTENT)
#

CreationTestCase and GatherTestCase pass

#

UpdationTestCase and DeletionTestCase get a 404

#

Im not sure why they are not working when in my postman it does

opaque rivet
#

when having nginx serve your compiled staticfiles (html/js bundles), is nginx technically acting as a cdn?

#

also can you use redis to cache pages with django? what's the use-case of caching pages? I don't understand the basics of it.

short ingot
#

whats should I use on my VPS Ngnix or Apache?

#

Im trying to deploy a flask machine learning applications

native tide
#

I have a problem with React Router

#

here is my App.jsx

#

The problem is that I don't see the content

#

In the Switch element

#

the Dashboard component is not being rendered

#

also... the Link components are in a different component

#

There are no errors in the console

#

It's just that I can't see the rendered component when I navigate to path='/'

thorn igloo
#

or add an exact attribute, if i remember correctly

native tide
#

yow it still doesn't work

thorn igloo
native tide
#

I updated this part jsx <Switch> <Route path="/create-loan"> <CreateLoan></CreateLoan> </Route> <Route path="/" render={(props) => { <Dashboard {...props} getTotalMoneyOfStatus={this.getTotalMoneyOfStatus} getTotalMoneyOfStatus={this.getTotalMoneyOfStatus} users={users} loans={users} />; }} ></Route> </Switch>

thorn igloo
#

give it the exact attribute

native tide
#

like this?jsx <Switch> <Route path="/create-loan"> <CreateLoan></CreateLoan> </Route> <Route exact="/" render={(props) => { <Dashboard {...props} getTotalMoneyOfStatus={this.getTotalMoneyOfStatus} getTotalMoneyOfStatus={this.getTotalMoneyOfStatus} users={users} loans={users} />; }} ></Route> </Switch>

thorn igloo
#

no

native tide
#

doesn't work

#

ok

#

the top one?

thorn igloo
#

see this example

native tide
#

I did thisjsx <Switch> <Route exact="/create-loan"> <CreateLoan></CreateLoan> </Route> <Route exact="/" render={(props) => { <Dashboard {...props} getTotalMoneyOfStatus={this.getTotalMoneyOfStatus} getTotalMoneyOfStatus={this.getTotalMoneyOfStatus} users={users} loans={users} />; }} ></Route> </Switch> I can see that the CreateLoan component is rendered.

native tide
#

Dashboard doesn't get rendered

thorn igloo
native tide
#

I need to use that render function so I can pass props to that component

thorn igloo
#

can't you pass props normally?

native tide
#

No

thorn igloo
#

bruh

#

what kind of props are you passing?

#

cause this worked for me

native tide
#

There is a bigger problem I think

#

The Dashboard components doesn't want to get rendered

#
<Switch>
                  <Route exact="/create-loan">
                    <CreateLoan></CreateLoan>
                  </Route>
                  <Route exact path="/d">
                    <Dashboard></Dashboard>
                  </Route>
                </Switch>```
#

I even removed the props and stuff

thorn igloo
#

hmm, i'm not sure what could be the issue. could be some error in the component

native tide
#

Ok now i

thorn igloo
#

try it with another component that works and see if the issue still persists

native tide
#

Ok now Im gonna looks stupid lol

#
<Switch>
                  <Route path="/create-loan">
                    <CreateLoan></CreateLoan>
                  </Route>
                  <Route exact path="/d">
                    <Dashboard
                      getTotalMoneyOfStatus={this.getTotalMoneyOfStatus}
                      getTotalLoansOfStatus={this.getTotalLoansOfStatus}
                      users={users}
                      loans={users}
                    ></Dashboard>
                  </Route>
                </Switch>``` This works
#

Now I have another problem

native tide
#

Can python do web frontend?

calm plume
#

@native tide Here's my essay on that

swift wing
random lava
#

Hi, anyone know why my json looks weird on javascript?

var test = "{{ testjson }}";
console.log(test)

output

[{&#39;time&#39;: 1620588041, &#39;open&#39;: 26, &#39;high&#39;: 26, &#39;low&#39;: 26, &#39;close&#39;: 26}]

json file

[{'time': 1620588041, 'open': 26, 'high': 26, 'low': 26, 'close': 26}]
calm plume
random lava
#

all good. i fixed it using | tojson

dawn heath
errant storm
#

Hello,
Is it possible to send a post request from the client side, receive a get request, then change a html element content without refreshing the page? something like this:

on keyboard input event listener -> client sends post request to server -> server sends back a request -> client side receives the request -> element content changed

#

I'm using flask as backend

outer apex
#

@errant storm absolutely! There's the .text() method while using the Fetch API. You could then insert that html into the DOM.
https://gomakethings.com/getting-html-with-fetch-in-vanilla-js/

stable hemlock
calm plume
#

You use HTML/CSS for frontend

#

Not Python

stable hemlock
vestal hound
#

there are ways but they’re not very mature

errant storm
#
async function fetchTitle(e) {
    fetch(`/post/search/title?q=${e.target.value}`).then(
        function (response) {
            return response.json();
        }
    ).then(
        function (json) {
            ele.innerHTML = json.title;
        }
    )
}

Why is ele's innerHTML [object Object]

#

nvm i accidentally return a json in a json, my bad

hollow cave
#

In django can I just log everything including TLS issues? Because.. I think I’m prevented doing this when the URI variable is only passable as a string when i would expect to pass multiple fields so it’s compatible with ldap.initialise() as I’m wanting to enable trace_level=2

orchid cove
#

which framework is the best for python web dev?

errant storm
orchid cove
#

hmm might start out with flask then, I have used falcon before and it came pretty good to me after a while

worldly furnace
#

how do you install flask

#

is it a program?

sinful coral
#

I'm having a lot of fun with Django + Wagtail.

worldly furnace
#

I just dont understand what the hell Django is, is it a program you install to write front end code?

#

I'm so lost

sinful coral
#

They're scripts that make the Python program do things.

errant storm
worldly furnace
#

So you need to learn Flask code to use Python code to link HTML with python code

errant storm
#

^^

sinful coral
#

No, Flask is Python.

#

You learn Flask abstractions and write Python to tell it what to do.

worldly furnace
#

It's a version of python code that helps interact with HTML?

orchid cove
#

@errant storm what anime is your pfp from?

errant storm
#

yuru camp

orchid cove
#

tanx

worldly furnace
#

Sorry i'm coming from simple PHP and HTML coding.

#

This seems so much more in depth

errant storm
worldly furnace
#

But i want to learn it just getting a bit discouraged

errant storm
#

it's jinja

sinful coral
#

@worldly furnace No. The versions of Python are 2.6, 3.9, etc. Flask is just a library written in Python.

worldly furnace
#

So its a library of functions

sinful coral
#

Yes.

orchid cove
#

oh yeah I've seen jinja used before with it, that's some funky syntax lol

worldly furnace
#

That interacts within python code.

#

So for instance if i wanted to post HTML code within PHP code i would have to "
echo" the code. Something similar to that?

sinful coral
#

When Python runs a Flask app, it generates a web server on your computer that listens for HTTP requests and responds with dynamic HTML generated by your app.

#

PHP functions a little differently.

worldly furnace
#

I'm currently learning python using the app mimo.

#

Just for the simplicities of the programming language

sinful coral
#

HTML isn't anything more than a string.

worldly furnace
#

So you just put HTML in the strings within the pythoh

#

Print('<button>Button</button')

calm plume
#

HTML is a markup language, nothing more, nothing less

sinful coral
native tide
#

Kind of like this for a snippet:

<!DOCTYPE html>
<html>
    <head>
        <link rel="shortcut icon" href="{{ url_for('static', filename='images/idrop.png') }}">
        <title>
            Main Menu
        </title>
        <style>
            table {
                font-family: arial, sans-serif;
                border-collapse: collapse;
                width: 30%;
            }

#

The {{}} is the magic

sinful coral
#

Jinja and Handlebars are examples of templating engines.

worldly furnace
#

that just pulls variables and such from python and implements inside HTMl

#

Okay so another problem im having is i followed the instructions to do the path for python, and after i created the variable for python i went to system variables to edit the path and the python link isnt in there

native tide
#

So add the directory where it exists and == done

worldly furnace
#

so just add the same directory there

#

this girl on youtube is talking about adding %% before and after

native tide
#

If you want to rely on windows system variables sure

#

%system32% etc blah...

worldly furnace
#

when i type in command prompt says python isnt installed, but it is.

native tide
#

Sure, it doesnt know the path

#

do this, type out the full path of python.exe and hit enter, if it works, then remove python.exe and copy pasta to path

worldly furnace
#

says 'is not recognized as an interanal or external command, operable program or batch file

native tide
#

Whats the path?

#

My guess is it has a space

worldly furnace
#

C:\Users\emjay\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Python 3.9

#

i dont think i selected add path when i installed

#

let me uninstall and reinstall with that option seleceted

native tide
#

Yep, no space

#

Start menu

#

and Python 3.9

#

So, you need a quote

#

"C:\Users\emjay\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Python 3.9\python.exe"

#

^ That would run if its python.exe being ran

#

I love me some lack of quotes with windows for good ole red team fun...

worldly furnace
#

so i add that as a path under environmental variable?

native tide
#

No

#

Run that, quoted on your command prompt. Verify python appears

worldly furnace
#

ok

native tide
#

If so, then simply copy:
C:\Users\emjay\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Python 3.9

And place in path. Notice I did not quote

#

Path knows about spaces, etc.

worldly furnace
#

nope.

#

can i share screen?

native tide
#

You can paste?

#

windows key + shift + s

#

native screenshot if youve win ten

worldly furnace
#

okay i typed version and it came up

#

So its installed.

native tide
#

So thats the dir, copy it to path and bob is your uncle

dusk portal
#

hey!

worldly furnace
#

This is going to be fun

#

Definitely so different than what im used to

last orchid
#

So I'm creating a webview app using pywebview, where my backend is in flask and the frontend is in a JS framework (Vue). I was wondering what the best practice was for picking ports and syncing them across the frontend and backend. Is there some nice way to do it or do I just have to rely on randomly picking a port and hardcoding it into both, and hope the users don't have something running on it already?

dusk portal
#

yeh i have just started django

#

can i get some suggestions to complete it fast and how to do that full plan anyone exp. in django ??

wooden ruin
dusk portal
#

and how should i learn it i mean the correct way

wooden ruin
# dusk portal how vast is django

django has a lot of features that come included as opposed to a lighter framework such as Flask or Express. like i said, I suggest taking a course or walking your way through things - routers, templates, views, models, requests, etc.

dusk portal
#

i have good exp of flask

#

is django harder then flask??

wooden ruin
# dusk portal is django harder then flask??

it depends. some may say it's easier, some may say it's harder. i think it's harder than flask because it's a heavier framework and might come with having to learn more concepts

native tide
#

^

dusk portal
#

ok im ready to start

wooden ruin
#

great!

dusk portal
#

hmm i always face this issue

#

i fix it but again face it

#
 python manage.py runserver
C:\essentials\python\python.exe: can't open file 'C:\Users\91834\manage.py': [Errno 2] No such file or directory```
#

@wooden ruin

wooden ruin
#

the manage.py file you are trying to run is not in your active directory

dusk portal
#

it is but

#

;-;

wooden ruin
#

type dir into your terminal

dusk portal
#

oh

#

lemme try\

#

05-2021 21:47 <DIR> .
09-05-2021 21:47 <DIR> ..
10-05-2021 11:29 <DIR> .idea
09-05-2021 22:22 <DIR> mysite

wooden ruin
#

yea so you notice how manage.py is not there @dusk portal ?

#

you probably need to cd into mysite

dusk portal
#

oh

#

@wooden ruin tysm

oblique kite
#

hello guys..
Need help on Generating Access Code using Django

proud lintel
#

Hi, I was trying to use django with celery and redis , redis server is password protected, so how can i pass my password to redis . I am receiving this error Cannot connect to redis://localhost:6379//: Authentication required
which seems reasonable because I am not passing password . I have tried CELERY_BROKER_URL = "redis://:mysecurepasword@localhost:6379"
but this also doesn't seem working.

proud lintel