#web-development

2 messages · Page 77 of 1

uncut rover
#

the thing is, whenever i update my models, and migrate them, it give me a massive error

#

thats the error

bleak bobcat
#

Probably because you had a charfield with the value "1st bool field" and you tried to change that field to a boolean field

vast remnant
#

Is anyone familiar with using the Fetch API and django? I am trying to access a json file and pass it to my front end, but fetch keeps returning 404.

median meteor
#

Is anyone here with Django experience? I daced some problem and stocked

uncut rover
#

ok, thx for your info

bleak bobcat
#

Easiest way to fix your problem @uncut rover is to destroy your database, create a new one, delete all migrations files, and then run the migrations again. There are other ways but they are a bit more complex, if you don't care about your current data I would just do that

uncut rover
#

Reset the whole thing?

bleak bobcat
#

Yea

uncut rover
#

Ill do that

bleak bobcat
#

The database only

uncut rover
#

and....

#

I think ill attemp to relearn flask

bleak bobcat
#

Right now this is not a flask or django problem that you have, it's a basic database problem where you're trying to convert a text column to a boolean column while keeping text data

near jewel
#

I have a problem, my flask app doesn't decode % characters from url parameters when on a2hosting shared(Uses apache if i'm not mistaken), but handles it just fine locally

for example for /test/foo%20bar
@app.route('/test', methods=['get'])
@app.route('/test/<title>', methods=['get'])
def test(title=""):
return title

When used on remote hosting it would return foo%20bar and on local it would return foo bar. Can't figure out why

bleak bobcat
#

You should slugify your url parameters

near jewel
#

But why does it work normally when running locally

#

And just does that on remote server

native tide
#

@formal shell Switch to back end

full nimbus
#

How can I use a godaddy domain to redirect to my website made with flask?

native tide
#

Oh so you probably want to launch that then. Or I guess at least purchase a name first. I would look that up on youtube. I think most people are still learning not launching websites here at this point but I could be wrong

#

@pure walrus I don't think it would be that hard

full nimbus
#

I bought a domain as a joke, but I want to take the opportunity to learn a little web design

native tide
#

I bought a domain as a joke, but I want to take the opportunity to learn a little web design
@full nimbus 2 things you need to know, SRV and A Records

#

once you got them covered you'll be able to setup ur domain in no time

#

and I am sure GoDaddy offer support for such queries

weak lynx
#

Hi! Im triying to link my .css to my html and it just doesnt work...

#

look

#

<head>
<link rel="stylesheet" type="text/css" href="main.css"/>
<meta charset="UTF-8">
<title>Page J</title>
</head

#

they are in the same folder

#

and i dont have idea what is happening

#

can someone help me plsss!?

native tide
#

Are you sure everythings saved

#

@weak lynx

#

Also if that code is exactly right you're missing a closing > at the bottom

#

What were you goiung to type ba

weak lynx
#

yes im sure

#

i dont know what is hapenning

#

i have been like 4 hours and anything

bleak bobcat
#

What is your full code ?

weak lynx
#

let me send it...

dark agate
#

try "./main.css"

weak lynx
#

ok

#

this is the home.html

#

<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" type="text/css" href="main.css"/>
<meta charset="UTF-8">
<title>Page J</title>
</head>

#

this is one part of main.css...

#

body {
margin: 0;
background-color: slategrey;
font-family: sans-serif;
font-weight: 300;
}

.container {
width: 80%;
margin: 0 auto;
}

#

try "./main.css"
@dark agate I try it and no, didnt work

dark agate
#

there's no body in your html document

weak lynx
#

if i click ctrl and click it goes to main.css

#

there's no body in your html document
@dark agate let me sen it

dark agate
#

okay

weak lynx
#

<header>
<div class="container">

  <nav>
      <ul>

        <li><a href="#">Home</a></li>
        <li><a href="#">About</a></li>
        <li><a href="#">Category</a></li>

      </ul>
  </nav>

</div>
</header>

</body>
</html>

#

the background dont change of color... anythin...

dark agate
#

hmm

#

html and css are in the same folder right?

weak lynx
#

Yes also i have triyed static folder outside the templates but dont work either

bleak bobcat
#

Do you know what the browser console is @weak lynx ? If yes open it, do you see any error ? If not, press F12 and go to the console tab

dark agate
#

you are using flask?

weak lynx
#

yes

you are using flask?
@dark agate

#

Do you know what the browser console is @weak lynx ? If yes open it, do you see any error ? If not, press F12 and go to the console tab
@bleak bobcat Yes!! it say theres a error 404 not found... but whyy??

#

with main.css but why?

#

if i click control in it it goes to main.css

dark agate
#

if u are using flask I think you have to use url_for to link the css

weak lynx
#

jmmmm can you say me how?

dark agate
#

like href={{url_for('static', filename='main.css')}}

#

but create the static folder and put the css in before doing that

weak lynx
#

ok...

dark agate
#

and try using ctrl+F5 to hard refresh

#

in your browser

weak lynx
#

static folder in or outside templates?

dark agate
#

outside

weak lynx
#

ok

#

like href={{url_for('static', filename='main.css')}}
@dark agate is this correct?

#

static is marking a error

dark agate
#

what is it saying

weak lynx
#

it shows me static in red

#

are there missing some""?

dark agate
#

do you have it like this?

weak lynx
#

let me see...

#

its....

#

ignore style.css its another think i was triying

#

@dark agate

dark agate
#

your server it's still on?

#

with debug mode

weak lynx
#

yes

#

i dont have idea what is happening

dark agate
#

I mean mine is working

#

I just go in localhost and it takes the css and everything

wild thunder
#

guys

#

i have my app deployed in heroku for testing

#

i want to put it "for real"

#

if i use amazon

#

how hard is it to deploy the app?

#

it uses python (flask) and sqlite (i want to change it to pgsql)

#

i need to implement payment methods too, but i'm a little worried about deploying

#

heroku basically does everything, how does amazon deal with it?

distant trout
#

someone point me to the right direction: how would I go about loading in data by clicking a "load more" button. Using flask by the way and the data is coming in from an API call.

rigid mist
#

Oh, i fixed it

mellow tide
#

👍

rigid mist
#

Sorry ill delete the message

coral raven
#

problems that solve themselves

mellow tide
#

@wild thunder Amazon does nothing and you have to do it all yourself lol

wild thunder
#

Oh

#

How to

mellow tide
#

@distant trout sounds like Js magic

wild thunder
#

😬

mellow tide
#

@wild thunder easiest, though not the cheapest, is to just launch an ec2 instance, put your app there, hopefully you have a way to run it as a daemon, open the ports, and use route 53 to point a DNS name at the instance.

#

If it's a container, you can use ecs, but you will need to do some lambda magic (unless the allow opening them up to the world now)

#

The best way to run in AWS with something flask-like is by not using flask and using chalice instead and just deploying to lambda instead

#

But even that requires some permissions knowledge

wild thunder
#

It's an flask app

#

I know nothing about this hahahha

#

Jesus, i'm Lost

mellow tide
#

Just stick to heroku until you have a reason not to

wild thunder
#

I mean, the objective is tô deploy on amazon

mellow tide
#

Until then, read up on the AWS fundamentals lol

wild thunder
#

I'm using heroku to check

#

It was my First deploy

#

I'm 9 months on programming

mellow tide
#

AWS has a lot of docs on how to deploy different things different ways (flask apps included), but none of them exist in the free tier, so plan to pay ~$30-60/mo for something small

#

Because they do it "the right way" and not the cheapest way lol

wild thunder
#

Where to deploy something cheap?

#

It's meant to be a ecommerce

#

I want to be able to upload files

mellow tide
#

With a bunch of static images, none of the "big three" will be cheap

austere crown
#

Hello, I am having issues with running some asyncronous functions from another file in my flask app to output some information to the browser. Here is the error:

File "H:\programming\personalSteamAuth\steamauthentication.py", line 72, in get_confirms
   loop = asyncio.get_event_loop()
 File "C:\Users\KUWUPA\AppData\Local\Programs\Python\Python38-32\Lib\asyncio\events.py", line 639, in get_event_loop
   raise RuntimeError('There is no current event loop in thread %r.'
RuntimeError: There is no current event loop in thread 'Thread-8'.

Here is the code in my flask app:

import steamauthentication as sa

@app.route('/_load_confirmations/')
def _load_confirmations():
    confirmations = sa.get_confirms() # <----- this is the line where I call the function from my other file
    print(confirmations)
    if len(confirmations) == 0:
        return "<p>No confirmations found,</p>"
    else:
        output = ""
        for confirmation in confirmations:
            output += render_template("confirmation.html", confirmation=confirmation)
        return output```
And here is the function from my other file being called:
```py
def get_confirms():
    global loop
    loop = asyncio.get_event_loop()
    asyncio.ensure_future(get_client())
    asyncio.ensure_future(get_confirmations())
    loop.run_forever()
    return out
#

Any help would be greatly appreciated :)

native tide
#

I use flask

quick cargo
#

You should not be using asyncio and flask together

austere crown
#

is there any way that i can execute this without having the flask app interfer with the output

#

because when i use the function from the command line it works to output the information i need

#

i just need some way of running this function in my flask app and gaining the return value from it

#

like i guess if there is a way i could have it run the function (on demand) isolated from flask but still get the return value in the flask app

jade folio
#

Hey, is there a way to send the flask responses back to the same html page in which the post request was generated?
Thank you for your time!

sacred crest
#

Hi all. Hope you're all fine.

austere crown
#

@jade folio are you talking about like an AJAX request to add a response to the current html?

jade folio
#

Yup

sacred crest
#

I've written two cron jobs and in one of them I'm saving the results in MySQL. Now I want to use Django to view those data in a website. My question is, do I need to do anything in Django about my cron jobs? or they can work quite independently near each other?

austere crown
#

yeah @jade folio you can do that by creating a new @App.route('/_example_route/') and having your button call the following function on_click: js function myFunction() { $.ajax({ url: "/_example_route/", success: function(output){ $("#[ID of element you want to add output to]").html(output) }

#

also in the route be sure to have it return the output you want to add to the html

jade folio
#

Thanks a lot for your help. Gonna try this right now.

austere crown
#

so for example ```py
@app.route('/_example_route/')
def _example_route():
return "More html"

jade folio
#

is it possible that the action attribute in a form prevents the following function from working?

austere crown
#

potentially

#

what action does the form have?

#

because maybe you could add that to the function you just created and set the forms action to myFunction() rather than using onclick

jade folio
#

used to specify a route to get the info entered in the form, as in action="/route"

what action does the form have?
@austere crown

austere crown
#

so maybe try set the action to call the AJAX function (in my example myFunction()) and add to that function a second ajax that calls the route which gets the info added to the form

jade folio
#

Could you kindly explain a bit how i could do that? Haven't got much knowledge with AJAX

austere crown
#

so for example:
html:

<form action="myFunction()">
form in here
</form>```
js:
```js
 function myFunction() {
    $.ajax({
    url: "/route to add data/",
    post: form data,
    success: function(output){
      $("#[ID of element you want to add output to]").html(output)
    }
    $.ajax({
    url: "/_example_route/",
    success: function(output){
      $("#[ID of element you want to add output to]").html(output)
    }```
#

some thing like this ^

#

so call the one function with the action

#

and have it do both your things you want

#

i dont really have that much knowledge in ajax either but I was doing something kinda similar using it the other day haha

jade folio
#

Got it but How do I access the data back in flask?

austere crown
#

it should be the post data

#

actually idk about that tbh

#

let me have a look

jade folio
#

Earlier used to access it through, request.form.get() Should use the same?

#

I cannot thank you enough for your help!!

austere crown
#

its all good haha
so you are using a button with type submit right?

jade folio
#

Yeah

austere crown
#

are you able to send the html for your form?

jade folio
#

<form action="/quote" method="post" onsubmit="check(); return false;"> <div class="form-group"> <input autocomplete="off" autofocus class="form-control" name="symbol" placeholder="Stock symbol" type="text" id="quote"> </div> <button class="btn btn-primary" type="submit">Quote</button> </form>

#

The check function currently is just used to check if all the parameters are filled

austere crown
#

ok so rather than having an action on your form what you could try is something like:

$(document).ready(function() {
  $form('[formid]').on('submit', function(event) {
    check();
  $.ajax({
  data: {
      quote : $('quote').val()
  
},
type: 'POST'
url: "/quote"
success: function(){
    $.ajax({
    url: "/_example_route/",
    success: function(output){
      $("#[ID of element you want to add output to]").html(output)
}
}



#

it may be mis typed but the general idea is to have a js function that waits for the event of the form being submited

#

and then getting the data inputed to the form

#

and sending it to the "/quote" url

#

then after that if it succeeds calling another ajax request which adds more html to the page

jade folio
#

👍🏻

flint breach
#

Django filters is preety nice

icy zinc
#

Hey! Do you know a usefull python library to make a social network?

short sierra
#
from django.contrib.auth.models import User
from django.contrib.auth.forms import UserCreationForm

class UserRegisterForm(UserCreationForm):
    email=forms.EmailField()
    class  Meta:
        model=User
        fields=['username','email','password1','password2'] ```
i get an error that says "local variable 'username' referenced before assignment"
#

any help?

icy zinc
#

You didn't declare it

short sierra
#

isnt it global

#

from the User thingy

native tide
#

@icy zinc I'm making social media app with flask

icy zinc
#

No

#

Thanks you cat

native tide
#

Hi! Hows does FastAPI compared to Express for a small team (<5)? I saw some blog posts said that Python required works to do sometimes for async, thread and etc. Meanwhile Node has those built-in.

untold flare
#

Hey, I keep getting django.db.utils.OperationalError: no such table: project_classname (not actual that name) which is referring to a class we have in models.py when making migrations. I tried deleting the database, but that didnt work, what can I to?

lofty matrix
#

Did you run migrate?

untold flare
#

that happened when running python3 manage.py makemigrations

lofty matrix
#

Oh

#

Are you trying to reference the model from a foreignkey somewhere where that model isn't imported?

#

And does the exception give any indication of what line of your code triggered it? I know the errors aren't always helpful as the whole stacktrace can be internal Django code

untold flare
#

there's the full trace

lofty matrix
#

authorize_page("internet") in generate_page.py

#

is this in a function?

#

or just in the root level of the file

#

I think it's root level because that line of the trace say "in <module>"

#

if that is the case, it looks like that is using the GeneratedPage model before it get's the chance to be created

icy zinc
#

To make a social network, is it better to use flask or Django?

coral raven
#

Django

#

You can use flask too, but lots of manual typing required

untold flare
#

if that is the case, it looks like that is using the GeneratedPage model before it get's the chance to be created
@lofty matrix let me look

lofty matrix
#

This might break your code as I don't know what that is doing, but if you comment that line, see if the makemigration succeeds

coral raven
#

use a database browser to see if the table you made has been created

lofty matrix
#

this is in the stage that generates the instructions for what tables to make, so the database itself isn't relevent yet

untold flare
#

This might break your code as I don't know what that is doing, but if you comment that line, see if the makemigration succeeds
@lofty matrix lemon_hyperpleased thanks!

#

it worked :D

lofty matrix
#

🥳

#

So you'll have to refactor your code so that isn't in the root of your module. Because it is, it is run when makemigration runs

twilit zenith
#

hello, can anyone hit me up with any django project code(github), intermediate-expert level, i would like to know how intermediate django programmers solve problems.

regal furnace
#

Good day! In my project I want to make library site. So I have book, it's author and it's genre. At home page I want to select a book from the drop-down list by its title. How can I implement this through the views.py and template files ?

late fjord
#

you want to implement filtering ??? @regal furnace

regal furnace
#

Let's say so at home page I have text field label and near it I want to make drop-down list from wich I can select a book via it's label.

#

I want just to choice book from list which I put at my admin page.

#

I'm not sure that it should be mandatory filtering

elfin bluff
#

i need help for making list of list:
A & M are two list:

im collecting some elements in A , and saving it in list M,
and where im clearing list A to collect new elements, my list M is also getting empty

M.append(A)
A.clear()```
regal furnace
#

So in my models.py I need to write filtering field?

#

Ok @late fjord I'll check it asap! Hope it'll help me!

late fjord
#

just watch the video but the drop down menu you need to use javascript I guess, and I can't help on that

#

I don't know how to use javascript

#

hhh

elfin bluff
#

need help with drop down ?

#

i mean where are you using droup down ? nav bar menu ?

regal furnace
#

Hmm, so let's try solve problem step by step. And I more take care about my models.py, views.py eith template

#

Yes @@elfin bluff
I want to use it at my home page. So I working now on library site. I have author, genre and book. And I want to implement near textfield label drop-down list of books which I have at my database(I put them at admin page)

brave elbow
#

Can someone help me. I am using vscode and it always tells me I have 'unresolved import' problems when I dont. For example, "from wtforms import <whatever>" always gets the red squigily underline. In the problems section of VScode it says unresolved import. However the modules are installed and the import is working correctly at runtime.

lofty matrix
#

I've had this problem too

#

(ignore that this is about pylint specifically)

brave elbow
#

Thank You @lofty matrix

last ginkgo
#

help

#
  File "C:\Users\wattow24\AppData\Local\Programs\Python\Python38-32\lib\site-packages\django\core\handlers\exception.py", line 34, in inner
    response = get_response(request)
  File "C:\Users\wattow24\AppData\Local\Programs\Python\Python38-32\lib\site-packages\django\core\handlers\base.py", line 115, in _get_response
    response = self.process_exception_by_middleware(e, request)
  File "C:\Users\wattow24\AppData\Local\Programs\Python\Python38-32\lib\site-packages\django\core\handlers\base.py", line 113, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "C:\Users\wattow24\Desktop\programming\python\PyWeb\main\views.py", line 24, in create
    return HttpResponseRedirect("/%i" %t.id)

Exception Type: UnboundLocalError at /create/
Exception Value: local variable 't' referenced before assignment```
#

code:

#
from django.shortcuts import render
from django.http import HttpResponse, HttpResponseRedirect
from .models import ToDoList, Item
from .forms import CreateNewList


def index(response, id):
    ls = ToDoList.objects.get(id=id)
    return render(response, "main/list.html", {"ls": ls})


def home(response):
    return render(response, "main/home.html", {})

def create(response):
    if response.method == "POST":
        form = CreateNewList(response.POST)

        if form.is_valid():
            n = form.cleaned_data["name"]
            t = ToDoList(name=n)
            t.save()

        return HttpResponseRedirect("/%i" %t.id)

    else:
        form = CreateNewList()
    return render(response, "main/create.html", {"form": form})
native tide
#

Hello! Which web framework is better? Django or flask?

#

For flask sessions, when the user reopens the website does their session reload?

quick cargo
#

@native tide not always

#

Usually sessions stay until X amount of time or the browser's cache and cookies are cleared

native tide
#

Gotcha. I'm just having issues keeping a user logged in across the website's pages. I've been using Flask-Login for it so far and I'm just wondering why it's not working as it should.

native tide
#

>>> x = User.query.filter_by(email='example').all()
>>> x
[<User 1>]

I'm using SQLAlchemy. Is there any way to make the query show me the actual information of User1, such as email, password within the terminal?

glass walrus
#

your result set is a list, so you should access the item in your list. like x[0].email

native tide
#

Thank you very much! @glass walrus I understand! The .all() gives a list as there may be more than one. Thank you.

burnt night
#

Question

#

i want to get into backend web dev...
I was getting used to using my frontend knowledge and moved over to webflow, but i want backend now so i can go full stack...
but i have no idea where i can host... any suggestions?

brittle basin
#

You can try to deply to Heroku

#

Though I'm trying it now for the first time and having a trouble lol

burnt night
#

is there a limit on free heroku?

brittle basin
#

I think it does

#

Not sure how much

burnt night
#

pretty much fresh out of school, but i'd like to start a lil thing of sorts

brittle basin
#

It great for fast deployment of small apps for free

#

It has some premium services too, though never tried

burnt night
#

fair fair

#

i also a bit worried about my design skill (or lack there of) 😂

brittle basin
#

A matter of practice

burnt night
#

Noted... thanks 👍🏿

brittle basin
#

Speaking of Heroku, I'm trying to deploy my app too, it uses gunicorn and flask. I came across a problem I can't seem to fix.
When I run the app locally it works fine.
But when I try to load it up in the dyno, it crashes

#

It doesn't seem to find the main package I have called "app"

#

Let me send an image of the file system

native tide
#

@burnt night If you signup to github student you get some sort of heroku subscription

#

Think it's something like a years hosting

brittle basin
#

Any idea why it fails to find the app package inside the dyno?

burnt night
#

@burnt night If you signup to github student you get some sort of heroku subscription
@native tide :o
thx

native tide
#

@burnt night link herehttps://education.github.com/pack

GitHub Education

The best developer tools, free for students. Get your GitHub Student Developer Pack now.

burnt night
#

WOOOW

#

cool

#

love to see it

royal oak
#

can someone spend time on private message with me on what i need use to create a website and what coding i need to do

i am a beginner

feral minnow
#

note: if you see there's no network activities

native tide
#

@royal oak If you want to learn about web development and you're interested in flask here's a good book

#

Also I found codecademy's course with flask a good explainer for the most part

royal oak
#

whats flask ??

native tide
#

A web development framework

royal oak
#

oh okay so flask is were i do my coding ?

native tide
#

No, you code with Python. It gives you functionalities for web development. I'd suggest you read into it yourself

royal oak
#

okay thanks

past cipher
#

does anyone know why I am getting permission error ?

topaz charm
#

Is it possible to have my Django views change daily by replacing the current info in my view with info randomly selected from my database? I.e each night at midnight, I want to select a new object from the database and place its information in my Django view.

quick cargo
#

templates™️

thorny dock
#

How do I get query parameters with FlaskAPI? I figured out path variables, but I'd like to use a query param

#

I'm also open to suggestions for REST api libraries

#

If you have something against FlaskAPI

#

(I usually use Go for REST stuff)

quick cargo
#

@thorny dock

from flask import request

e.g url = "xyz.com/bob?name=jim&age=123"

name = request.args.get("name")
age = request.args.get("age")```
#

Flask is a really stable framework and incredibly user friendly, its certainly not the fastest tho if you're aiming for speed then flask isnt your thing, but overall flask is very powerfull

round tinsel
#

I prefer Flask over Django for example due to Flask's relative simplicity.

thorny dock
#

I'm not building a full backend with it, just a JWT microservice, so speed would be preferable. I only have two endpoints, /issue and /verify

zinc hill
#

hi not relate to python but I was wondering if anyone can tell me what type of image this call?

quick cargo
#

Svg?

#

Pretty sure 'offical' name for them are vectorgraphs

#

Example

weak lynx
#

Hi im kind of new in web development and i having a problem... im creating posts but when i put the second one it dont go under the first it apppear overlapping my first and i dont know why... can someone help me?

mellow tide
#

@weak lynx check your css, that's literally the only thing it could be

weak lynx
#

i will send it... @mellow tide

#

.review1 {
position: absolute;
margin-left: 134px;
margin-right: 250px ;
margin-top: 45px;
border-style: solid;
border-color: rgb(0, 0, 0);
border-width: 2px ;
padding: 30px;
padding-right:270px;
padding-top: 15px;
font-size: 17px;
}

#

How can i create a exact same of those under the first and then under the second...

mellow tide
#

Don't try to do it yourself, there are plenty of frameworks that do it for you. See "bootstrap"

#

Honestly, if you don't learn the frameworks that are out and about, you will be at a disadvantage in job hunts

#

And usually I'm a stickler for "learning the basics", but frontend web is very framework-centric

warm igloo
#

You definitely don't want position: absolute @weak lynx

If this is a div and you're stacking them one right after another, they'll default to being the way you really want them. No position needed at all unless you're doing something I can't imagine at the moment.

weak lynx
#

@warm igloo Yes thanks, i delete it and it works... now i have a little problem with some images but i will fixed it

#

thanks

tight grotto
#

why does my code not work

native tide
#

@tight grotto I'd say you send us a traceback of the error..we don't know what "doesn't work"

#

Is Flask a good fit in the microservices architecture? I've seen plenty of people and frameworks relying more on Java rather than Python and this makes me reconsider whether I should keep going with Flask. From your perspective, is an online-store built upon a microservices foundation achievable with Flask as a micro web framework?

native pasture
#

@native tide I think it depends more on how you implement your microservice architecture. As far as web/HTTP backend framework per se, you can probably be as lightweight as Flask even with Java, but I have no experience on the latter. If you're familiar with python you're probably better off with Flask, which is not bad at all for most web applications.

bronze quarry
#

Python is no longer suitable for Web Development

#

i say this after 4 years in DJango and 2 years in flask

#

the documentation is now starting to drift behind as i see a lot of these projects being updated maybe one or two times a month

rigid laurel
#

that's

#

that's such an incredibly wrong hot take

bronze quarry
#

Node is absolutely ungulfing the web development world, and a lot more projects in Go and Rust are on its way

#

Also, in terms of performance, Python is extremely slow

#

spinning up a $5 general server on Digital ocean and puting a Flask-SQLAlchemy / Marshmallow project on will only give me a benchmark of maximum ~500req/s

#

just simplying returning a small json body

#

node can easily do 2k

#

per second

#

rust and go

#

even more so

#

2010-2017 was RoR vs Python. now its node and performance languages

quick cargo
#

The diffrence is Node acts as a async type system

#

If you actually Ran Flask with gevent like most people using it for APIs you'd find a very large increase in performance

bronze quarry
#

even if that was the case, performance in go, rust, scala. or even in older lanaguages like Java or C++ in unreachable for Python

quick cargo
#

yes because theyre compiled

#

but people dont care about performance they care about how quick it is to develop and train people on

bronze quarry
#

yeah, my team made the decision today to switch to Go / Node to keep up with the times

#

we're sunsetting all our Flask apps

#

which arelike 4 of them

flint breach
#

look up uvloop, if you're squeezing for performance

quick cargo
#

uvloop doesnt work with flask

bronze quarry
#

NOde is easier to teach than Python nowdays

quick cargo
#

the issue is they're comparing one of the slowest frameworks to a async node system

bronze quarry
#

There is way more updated documentaiton on Node than Python

flint breach
#

that's your opinion

bronze quarry
#

I think its quantifiable

quick cargo
#

your claims are very questionable tho lol

bronze quarry
#

I mean, it's pretty obvious that Node would engulf the world in web development - One language for the entire stack

flint breach
#

i understand python is not natively meant for perfpython is very mature, the docs are very clear and concise, very easy to pick up

quick cargo
#

i mean no, Node has been around long enough to show itself

bronze quarry
#

one of the biggest issues my team had with python was how difficult it was to use package managers

quick cargo
#

🤔 Then your setup must be rather scuffed

bronze quarry
#

we used pip originally and we liked that, but were suggested to change to pipenv in which hell broke lose for us

#

reverted back to pip, and then ended back up on poetry

#

Currently, we dont find the python ecosystem sustainable, and find node and go's way more productive in the long run

flint breach
#

can't complain about node, although the npm/modules ecosystem, yikes

quick cargo
#

wait... Do you just.... deploy without any containers or any decent organisation

bronze quarry
#

yeah we're pretty small, we're not really dealing with docker or terraform

#

we have 5 microservices that we handle

quick cargo
#

and yet you have a go at flask for being slow lol

bronze quarry
#

im sorry?

flint breach
#

go is nice for microservices ngl

quick cargo
#

go is pretty nice

bronze quarry
#

containerization will not help improve speed and performance

quick cargo
#

no but running flask with gevent would massively increase performance

#

not that it matters considering the system is normally slowed down by other systems but if you really want performance you'd use a ASGI instead of WSGI

bronze quarry
#

yeah we're using uwsgi

#

we have looked at other frameworks such as starlette and falcon

#

but the development and environment just doesn't seem there for us

#

it was very questionable where these projects would end up in 2-3 years

#

we just had to go with Node in terms of this

quick cargo
#

i mean they've already existed for longer than that

bronze quarry
#

node's security for the future is just that much greater

quick cargo
#

🤔 Even tho most npm modules arent maintained after a year

bronze quarry
#

well, that's debatble

#

i consider node's ecosystem way more livlier and active

quick cargo
#

🤷 you do you ig

#

if you wanted speed so bad you might aswell run with Go over node in that case

flint breach
bronze quarry
#

yeah Go is needed for our websocket servers

quick cargo
#

just just use Go for all of it lol

bronze quarry
#

node will handle most of the auth and just general routes

#

well, its not necessary, our devs are already working on node

flint breach
#

god bless npm

bronze quarry
#

lol

quick cargo
#

npm is a meme lol

bronze quarry
#

weekly downloads 500k

#

that's hilarious

flint breach
#

if you're using webpack, you're using this package 🙂

bronze quarry
#

seriously?

flint breach
#

:), that's why i think this ecosystem is a joke

quick cargo
#

over half the JS community have no idea what they're doing

bronze quarry
#

well, this is just a one off situation, but definitely a questionable choice by webpack

#

in general, js seems to be alive

quick cargo
#

so is python lol

flint breach
#

well, that's definitely not false

#

but so is python ^

bronze quarry
#

i am feeling the death of python unfortunately

flint breach
#

Uhm

bronze quarry
#

im getting so many outdated SO stuff

quick cargo
#

🤔 Then update your modules lol

bronze quarry
#

SO

#

StackOverflow

quick cargo
#

oh yeah mb

bronze quarry
#

Answered 2 Years Ago

quick cargo
#

but why do you even use Stack overflow

bronze quarry
#

its helpful sometimes

#

i use this place too

quick cargo
#

you should atleast be beyond needing to SO everything instead of actually reading the docs

bronze quarry
#

yeah that's the thing, Flask-SQLAlchemy and tying CElery together doesn't have docs

#

i have to rely on SO answers

flint breach
#

well 3rd party integration is a different subject then native python libs

#

that's the responsobility of the lib owners

#

well, not really a responsibility

#

it's open source 🤷‍♂️

bronze quarry
#

stack overflow question that i recently had to spend

#

20+ hours on

#

no joke

#

actually 20 hours is exaggerating

#

numerous hours*

quick cargo
#

I cant comment on that because i dont use Flask generally

flint breach
#

also not a very mature package

quick cargo
#

df is celery even

bronze quarry
#

celery helps with async operations

flint breach
#

that's not distinct for python though, if you need some specific use case, you'll likely find a not-that greatly supported lib for it

#

celery is basically a queue of workers for handling processing

quick cargo
#

You went with Celery over a mature lib like Gevent or pyuv?

flint breach
#

celery is very mature

#

uses gevent underneath afaik

west arrow
#

There is way more updated documentaiton on Node than Python

Lmfao. stop.please. Just one week I spent trying to solve an interview question and there was barely anything on the web. Lol

@bronze quarry

flint breach
#

or some type green threads - can't recollect

quick cargo
#

according to their description its a Queue system

bronze quarry
#

if you have an expensive task to run and don't want to block the main thread

#

you use Celery

#

we use it to set off timers in our system

flint breach
#

actually uses rabbitmq/redis for the queue itself

bronze quarry
#

yeah redis

flint breach
#

basically it's a distributed task framework

quick cargo
#

they're essentially trying to act like a async framework

flint breach
#

essentially, sure

#

async, parallel, concurrent, distributed

#

these are different things

#

well, async is basically a sub category of concurrency

quick cargo
#

async is just the blanket coverting of parallel and concurrent

flint breach
#

parallel and concurrent is different though

#

that's my point

quick cargo
#

yes but they're both used to create asynchronous systems

flint breach
#

true

native tide
#

@quick cargo How could you use selenium to click a checkbox if the checkbox doesn't have an ID

native pasture
#

@native tide css selectors?

native tide
#

er what does that mean @native pasture

rigid laurel
#

Node docs are amazingly bad

native pasture
native tide
#

alr

#

im so confused aaaaaa

#

Is that for selenium and python for clicking boxes?

flint breach
#

tbh, node and python docs are preety good, i don't get what's with the language circlejerk

native pasture
#

@native tide Google selenium css selectors and you'll find what you need

native tide
#

@native tide Google selenium css selectors and you'll find what you need
@native pasture Is there an ID for every single checkbox

#

It's just a checkbox of an official website, may I dm you it and you find out the ID?

rigid laurel
#

Node docs have been woefully inept for me in the past. ArrayBuffer stuff specifically caused me a bunch of problems from lack of clarity

#

and in general, I feel like the Node ecosystem has much worse docs

quick cargo
#

Ive never been very interested in learning the Node eco system

#

seems pretty pointless to me

rigid laurel
#

well - Node is great for going from 0 to something quickly

#

and the speed of it is relevant sometimes

quick cargo
#

If really want speed id go with Go or Rust depending on the level required

flint breach
#

a specific tool for a specific task 🤷‍♂️

#

just like most tools

native tide
#

Do you guys know of any resource/book that builds a simple python microservice (preferably with Flask) together with a load balancer and service registry? I m trying to migrate an old project (from scratch since it's easier) to use microservices, I know the building blocks and frameworks I should use but I can't figure out how to glue them together.

rigid laurel
#

Node gives a good compromise between speed of code and speed of development

nova sleet
#

hi

#

I'm wondering if It would be possible to set up a temporary web server using flask that would be accessible by other computers (not on my wifi [in fact, in another continent])

scenic vapor
#

in my Flask API
im listening to a 3rd party post request
i can't seem to get the post body in json

POST /webhook/ HTTP/1.1
Connection: close
Host: 127.0.0.1
Content-Length: 346
Content-Type: application/x-www-form-urlencoded

  id="W_79pJDk"
  &collection_id="599"
  &paid="true"
  &state="paid"
  &amount="200"
  &paid_amount="0"
  &due_at="2020-12-31"
  &email="api@billplz.com"
  &mobile="+60112223333"
  &name="MICHAEL API"
  &url="http://billplz.dev/bills/W_79pJDk"
  &paid_at="2015-03-09 16:23:59 +0800"
  &x_signature="f0ff6c564f98d5403e2b26fbd3d45309c76eb68d8c5bcda0d48b541c3502a396"
Body formatted for readability.

heres how the post reqest looks like
i've tried request.get_json(), request.form.keys(), request.get_data()

@app.route('/api/billplz_callback', methods=['POST'])
def billplz_callback():
    data = request.get_json(force=True)
    print("from billplz: ")
    pp.pprint(data)

    return 'hello'

this returns None

cold anchor
#

the API isn't sending you JSON, when you're trying to read JSON

cloud path
#

guys do you know any good tutorial to learn django?

devout coral
#

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

The code for this series can be found at:
https://github.com/Core...

▶ Play video
cloud path
#

thanks

native tide
#

from my views.py file i am trying to import

#
from django.shortcuts import render, redirect, reverse
from django.http import HttpResponseRedirect
from .models import Subscribe
from django.core.mail import send_mail
from django.conf import settings
from .forms import SubscribeForm

def foo():
  return 'foooooooo'

# Create your views here.
def home(request):
    context = {'text': 'Thanks for Subbing'}
    return render(request, 'subscribe/home.html', context)


def index(request):
    if request.method == 'POST':
        subscribe_form = SubscribeForm(request.POST)
        if subscribe_form.is_valid():
            subscription = Subscribe(
                name=subscribe_form.cleaned_data['name'],
                email=subscribe_form.cleaned_data['email'],
                send_gap=subscribe_form.cleaned_data['send_gap'],
                country=subscribe_form.cleaned_data['country']
            )

            send_mail('subject', 'this is a message', 'testkenny00@gmail.com', [subscription.email],
                      fail_silently=False)

            subscription.save()
            return redirect('home')

    else:
        subscribe_form = SubscribeForm()
    context = {'form': subscribe_form}
    return render(request, 'subscribe/index.html', context=context)
#

when it reaches the line from .models import Subscribe

#

i get this error

#

ImportError: attempted relative import with no known parent package

#

but i am not running the views.py file but send_every.py

#

send_every.py looks like this

#
from apscheduler.schedulers.blocking import BlockingScheduler
from views import foo

sched = BlockingScheduler()

# Schedule job_function to be called every two hours
sched.add_job(foo, 'interval', seconds=30)

sched.start()```
#

how do i fix this?

coral raven
#

from models import Subscribe @native tide

short sierra
#

I have been using Linux today I installed windows I tried to run python manage.py runserver but I get nothing back anyhelp?

coral raven
#

python3

short sierra
#

same prob

coral raven
#

open a terminal and type python --version, python3 --version

#

see what version it throws

short sierra
#

wtf I get nothing back

#

al tho I installed python

coral raven
#

just type python and see if the shell opens

short sierra
#

no it doesnt

#

it opens windows store

coral raven
#

python3?

fickle basin
#

hello @everyone

short sierra
#

3.8

#

the on I installed

#

but it open 3.7

#

in windows stor

#

e

coral raven
#

what linux distro?

short sierra
#

I used to have manjaro

#

now windows

nova sleet
#

I've started learning flask + socketIO to create webservers. Me and a friend are trying to do a thing, but we are... far to say the least (like halfway across the world). I created a webserver hosted on my public ip address, but he couldn't connect to it. The server did show evidence of him trying to connect, but it would always time out. Is it possible for people this far apart to connect with a url with an ip address, and if it is, what are we doing wrong?

fickle basin
#

i am facing an issue with django i have 3 apps in my django project and i can't manage to access templates from the store app

short sierra
#

I installed iit from Microsoft store it works now

coral raven
short sierra
#

thanks

fickle basin
short sierra
#

@coral raven the pc think I don't have it at all

fickle basin
short sierra
#

u don't have store.html

fickle basin
#

@short sierra yes i do as you can see in the tree

short sierra
#

in templates -> store ->

#

dude

#

am I blind ?

fickle basin
short sierra
#

I guess I am x

#

d

fickle basin
#

but if i use urlpatterns = [
path('store', views.store, name='blog-store'),
]
instead of urlpatterns = [
path('store', views.store, name='store-store'),
]
it works

coral raven
#

@nova sleet About that if you are running a local host, your friend cannot connect to it. You can use ngrok to make a temporary server to which he can connect

fickle basin
#

@short sierra any idead how to handel it ?

nova sleet
#

It wasn't 127.0.0.1 if that's local host. It was my public ip, but I'll look into ngrok @coral raven

coral raven
#

setting up ngrok is easy

#

pip install pyngrok
then once you have your server running
open a new terminal and type ngrok [port_number_where_server_is_running]
It will spit out a weblink
If you close the terminal the server will close
@nova sleet

nova sleet
#

oh

#

that seems really easy

#

so quick q

#

would local host be ok in this case, when initially starting the server, or does it have to be my public ip?

coral raven
#

yes local host is fine

nova sleet
#

okely dokes

coral raven
#

also you can see all the requests in the new terminal you made

nova sleet
#

downloading pyngrok failed

#

AttributeError: module 'importlib._bootstrap' has no attribute 'SourceFileLoader'

#

was the final error

#

@coral raven

coral raven
#

Wait let me see

nova sleet
#

nvm I fixed it

#

found a stack overflow post

coral raven
#

cool

#

What was wrong

#

just curious

#

@nova sleet

nova sleet
#

I had to upgrade ensurepip

#

not sure what it did, but it worked after that

coral raven
#

@nova sleet
one correction its ngrok http [port_number]

nova sleet
#

I saw

#

thank you so much it worked!!!!!!

agile fern
#

how to convert doc to pdf in python on linux??

native tide
#

Yo wassup

#

Do I post here abt web scraping?

indigo kettle
#

hey any flask ppl here? ping or DM me?
Thank You!!

snow dragon
#

@indigo kettle !ask

#

!ask

lavish prismBOT
#

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

• Don't ask to ask your question, just go ahead and tell us your problem.
• Don't ask if anyone is knowledgeable in some area, filtering serves no purpose.
• Try to solve the problem on your own first, we're not going to write code for you.
• Show us the code you've tried and any errors or unexpected results it's giving.
• Be patient while we're helping you.

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

indigo kettle
#

shall i DM u?

snow dragon
#

@indigo kettle No. See point 2 above, and if you need help beyond general discussion see #❓|how-to-get-help

indigo kettle
#

alright sry!!

snow dragon
#

No problem.

elfin gyro
#

Hello everyone. Can someone explain me how to make my buttons in html work with flask. Basically I made a button that should redirect me to another template of mine and just doesnt.

#
from flask import Flask, render_template, request, json

app = Flask(__name__)

@app.route("/main.html")

def naslovnica():
    return render_template('main.html')

@app.route("/o%20timu")
def onama():
    return render_template('o timu.html')

if __name__ == "__main__":
    app.run(debug=True, host="0.0.0.0", port = 80)```
#

this is the code

mellow tide
#

your template would matter more, unless it's a python error you see

elfin gyro
#

It's not a python error. When I click the button I get like error web page instead of my redirected web page

#

I mean, I dont get any errors in the console...

native tide
#

i'm kind of new, but i can't get my website to locate my css file

elfin gyro
#

@native tide Make sure your css file's location is correct.

#

You need to have this line in your <head>

<link rel="stylesheet" href="styles.css">
#

But change style.css into your file's location.

warm wren
#

Hello, I hope that I am asking within the correct channel but I have an enquiry which I haven't really had an sound response:
I am looking to develop a personal blog website using python. I am not sure if I should be doing this in Django or Flask?
I am of a beginner with Python and python is the first programing language I have learned. Would anyone be able to provide me with some good advice? I would really appreciate any response. Thanks.

mellow tide
#

@warm wren Django has everything you could possibly need built in, but it's a steeper learning curve ... flask is easier to learn, but you have to bolt everything together yourself with libraries.

frank vine
#

Building a blog site in django would require more upfront investment to get the site set up as django is more complicated than flask.
Building a blog site in flask would be simpler, but you will end up writing more and more features by hand to manage things as you want to add more features.

If you're very new to Python, it might be a good idea to use flask as it is simpler to understand and will require less effort to get something very basic working. I'd recommend using something like heroku to host your blog since it's simple to get started and you won't have to worry about managing a server.

native tide
#

Hey guys

#

So, I just knew scraping site like this is illegal https://www.whoscored.com/Statistics but I want to learn web scraping with a website that has pagination but without different urls. How can I do that?

frank vine
#

If you want to learn how to scrape a paginated site, why not create a test site that has pagination? At least that way you can learn how to deal with the different methods of pagination (scroll IDs, offsets, counts, etc.)

warm wren
#

@frank vine Thank you so much for your response! I really appreciate it.
@mellow tide Also thank you!

native tide
#

If you want to learn how to scrape a paginated site, why not create a test site that has pagination? At least that way you can learn how to deal with the different methods of pagination (scroll IDs, offsets, counts, etc.)
@frank vine create a test site? No way. Firstly, I don't have time to do that. Secondly, I won't manage to create such stuff

wild thunder
#

Hey guys!

I'm with a little problem:

i want to use the value from an html select field in an url,

like foo.com/25 where 25 is the size

how to do it using an select field?

#

I need jquery?

frank vine
#

@native tide

import json
import os
import sqlite3
from flask import Flask, request

fruit = [
    'apples', 'bananas', 'cherries', 'damsons', 'figs', 
    'grapes', 'kiwis','limes', 'plums'
]
if not os.path.exists('fruit.sql'):
  with sqlite3.connect('fruit.sql') as db:
      db.execute("""CREATE TABLE IF NOT EXISTS fruits (
      name text
    )""")
      db.executemany("INSERT INTO fruits (name) VALUES (?)",
                    [(x, ) for x in fruit])
      db.commit()

app = Flask(__name__)

@app.route('/')
def page():
  offset = request.args.get('offset', 0)
  count = request.args.get('count', 2)
  with sqlite3.connect('fruit.sql') as db:
    cur = db.cursor()
    cur.execute("SELECT * FROM fruits LIMIT ? OFFSET ?", (count, offset))
    response = cur.fetchall()
  return json.dumps(response)

app.run()

There is a super naive implementation of an offset-count paginator. You can use that to learn how to scrape that kind of paginated sites. There are more sensible ways of doing this (this implementation has no input sanitisation or use models in, say, sqlalchemy which comes with better pagination logic) but this is sufficient to learn. It took me about 10 minutes of fiddling around. I'd really recommend you practice writing these little bits of code so that you can make these little experimental programs; it's really beneficial.

sudden grail
#

Hey, what do you all guys think is better for productivity and small-medium sized teams: a real time chat app like slack or a threaded chat like twist?

weak lynx
#

Hi! I hope you all are good... can someone say me the best hosting free?

native tide
#

Javascript vs Flask or Django

#

which one?

quick cargo
#

I mean you just listed a Programming lanuge a micro framework and a full framework

#

idrk what you want us to say about the entire language of js lol

keen acorn
#

Hey does anyone know how to prevent passenger_wsgi from getting overwritten?

#

I am dealing with Namecheap hosting and almost every time I do git pull it changes my passenger_wsgi gets overwritten back to

#
import imp
import os
import sys


sys.path.insert(0, os.path.dirname(__file__))

wsgi = imp.load_source('wsgi', 'app.py')
application = wsgi.application```
#

Which is very annoying because even if I change my application name to app.py and put it on the same directory as the passenger_wsgi.py it still doesnt work

#

I always have to change it back to

#
import os
import sys


sys.path.insert(0, os.path.dirname(__file__))

# noinspection PyUnresolvedReferences
from main import app as application
#

almost every time I do git pull
To be clear, the passanger on my repository is the correct one, but for some reason when I restart the python app with the button on cPanel, it gets overwritten by the first default one which doesnt work at all

celest torrent
#

I've posted a Django question in #help-chestnut if anyone is free to help :)

lone moat
#

hey anyone here worked with django-celery?

#

needed some help regarding the same

rose vale
#

How can i call a function from flask?

lofty venture
#

Hello, im just learning to use django, im absolutely new to web development and i'd like to learn a bit of html to complement.

can you recommend me some good place to learn?

storm inlet
weak lynx
#

hi can someone help me creating a procfile for heroku?

#

i dont know how to do it 😦

warm igloo
#

I've only had to make one once for a Flask app, @weak lynx

What is yours supposed to run?

For instance, my Procfile is a single line:

web: gunicorn wsgi:app

brave bolt
#

he ytherre

#

so hoow does everyone store/updatte their flask keyss

native tide
#

**I'm getting an error in visual studio code where it says

Unable to import 'django.urls'pylint(import-error)**

wild thunder
#

guys, sorry if i'm interrupting, i tried in stack overflow and other sources, but i'm not finding how to

i want to pass my model data to javascript inside flask application

like

entry = {
id = object.id,
title = object.title}
#

how can i do it?

#

i tried {{object.id}} but had no success,

lethal igloo
#

@wild thunder do this

    final_graph_data = JSON.parse({{final_graph_data | tojson}})
{% endblock %}```
#

and on the server side

#

pass this in render_template final_graph_data=json.dumps(final_graph_data)

wild thunder
#

so, it would be like:

{% block javascript %}
object = JSON.parse({{ object | tojson}})
{% endblock %}

#

?

lethal igloo
#

yes yes, but remeber to make it json on the server side , that I wrote beneath that @wild thunder

wild thunder
#

alright

#

i'll do

#

one sec

#

got this :
TypeError: Object of type Product is not JSON serializable

#

it's an SQLAlchemy Model

#

class Product(db.Model):
etc

#

do i need to create an @property with the data i want to send?

lethal igloo
#

see anyhow create a dict data str on the server side do a json.dumps there and send it via render_template and then do a json.parse . That's it

#

@wild thunder

wild thunder
#

i'm on it

#

1 minute

#

well it kinda worked

#

but do i need to use all that {% jinja lingoo%}

#

all the time?

#

or just the json.parse

lethal igloo
#

well after parsew now you have javascript object now you can do anything with that

#

@wild thunder

wild thunder
#

i mean, i want to send it to my serverside

lethal igloo
#

after data manipulation send data to server side via any api call lib, like if you're using jquey then it is $post or $ajax or if you're using vanilla js then there is simple request library

wild thunder
#

oh

lethal igloo
#

@wild thunder google it it's easy, I am out now

wild thunder
#

i was mistaken, i'm sorry

#

i was putting my {% javascript block %} out of an js tag

#

it was rendering it in the page instead of keeping it in the background

lethal igloo
#

put that above <script> tag

wild thunder
#

yes

#

it worked

#

thank you so much @lethal igloo

lethal igloo
wild thunder
#

but now

#

        var entry = {
            titulo: produto_json.titulo,
            moldura: second_box,
            id: produto_json.id,
            price: price}

#

i want to send it to serverside

#

and i'm getting method not allowed

#

my route is 'post' only

foggy coral
#

anyone used scrapy for web scraping and can comment on whether it is worthwhile versus simply writing one's own web scraper with say, requests and beautiful soup?

unborn sphinx
#

How to add buttons?

#

can we add tkinter?

#

can we add tkinter to flask?

native tide
#

I am using pycharm for my IDE. I am also using django. I changed my css code but it is not changing on the site. I even deleted everything in the css file and it still is not registering that i deleted it on the website. I ran the server and went to the link, and pressed view page source and located my css file, and it says i still have all of my old css stuff on it, but i changed it, it's just not registering.

ripe goblet
#

I am using pycharm for my IDE. I am also using django. I changed my css code but it is not changing on the site. I even deleted everything in the css file and it still is not registering that i deleted it on the website. I ran the server and went to the link, and pressed view page source and located my css file, and it says i still have all of my old css stuff on it, but i changed it, it's just not registering.
@native tide can i have a look at your code? did you add it to static?

#

also get a help-channel 😗

unborn sphinx
#

ok

#

thanks

narrow crypt
#

Please help me with this issue, trying this whole thing since 2 weeks but couldn't solve.

spring jasper
#

I've been learning Python for about 6months now. I'm trying to do more web stuff and feel like there is so much more support for javascript based setups rather than Python/Django. Instead of doubling down on Python and learning python, should I bite the bullet and head down a javascript/node etc track?

vestal hound
#

I've been learning Python for about 6months now. I'm trying to do more web stuff and feel like there is so much more support for javascript based setups rather than Python/Django. Instead of doubling down on Python and learning python, should I bite the bullet and head down a javascript/node etc track?
@spring jasper
well, JS is unparalleled for frontend stuff

#

but if you're talking about a backend API...Python is fine.

rigid laurel
#

If you want to do web the modern way, then you need to do single page applications which require JS or something that transpiles to JS

#

and if you're doing the frontend in JS, NodeJS for the backend is fine - probably easier to jump into than a mix of python for the back/JS for the front

celest torrent
#

I'm having trouble implementing model constraints. If anyone can help, I've posted on Stack Overflow

https://stackoverflow.com/questions/63354263/field-required-when-another-field-is-populated-using-constraints-in-django-pytho

spring jasper
#

Awesome thanks @vestal hound abd @rigid laurel

oblique token
#

I am using django's built in method to reset the password for a user. I am getting this error. Can anyone help?

flint breach
#

EMAIL_USE_TLS

#

?

#

make sure to set the appropriate setting variables

weak lynx
#

Hi im triying to deploy a flask and python web into heroku but its getting me H10 app crashed, can someone help me please??

barren stratus
#

How to use break in jinja 2

oblique token
#

EMAIL_USE_TLS
@flint breach Oh, i found a typo in my code! Thanks

native tide
#

Why is it not working when i make a new python file in my app folder and try to import for example models in that file

#

FOR EXAMPLE

#

my dir looks like this

#

I want to import a model from the models file in fill_database.py

#

but i get this error django.core.exceptions.ImproperlyConfigured: Requested setting INSTALLED_APPS, but settings are not configured. You must either define the environment variable DJANGO_SETTINGS_MODULE or call settings.configure() before accessing settings.

#

the fill_database file is this

#
from models import ArticleWord
from scrape_words import all_words

for word in all_words:
    a = ArticleWord(word=word.word, article=word.article)
    a.save()
flint breach
#

what is the purpose of this file?

#

basically, django imporrts all the files you have, and executes them, you're iterating over all your "words" and then creating an object, when the django hasn't done the startup process yet

native tide
#

i don't know what you mean

bleak bobcat
#

Are you trying to run the file fill_database.py directly ?

#

That's what the error is suggesting

native tide
#

yes i am runnung fill_database

wild thunder
#

guys, good morning

I'm already losing my mind, on at least 3 stackoverflow questions i got my "answer" but this s*** is still not working.

i'm starting with js now, had no prior experience at it

#

i'm trying to get the value from a select field

#

i'm like 8 hours trying this and had no sucess, the only way i manage to do it is passing the function with (this) inside, but i don't want to get the value just interacting with it

#

can anybody help me?

bleak bobcat
#

document.getElementById("your_select_id").value

wild thunder
#

cool

#

that is not working

#

idk what is the problem

#

i'm using chrome

bleak bobcat
#

Ok, do

console.log(document.getElementById("your_select_id"))
console.log(document.getElementById("your_select_id").value)

please

celest torrent
#

Are you trying to get the text or the 'value'? In a select field, they're different

wild thunder
#

its returning undefined

bleak bobcat
#

First one or second one ?

wild thunder
#

1 sec

#

i'll try that snipp

#

i'm using flaskforms

{{ checkout.tamanho(class="form-control", id="SizeList", required='required' ,type="text", onchange="getSize(this)") }}
<div class="row left-10" id="SizeList">
         <b>
            <p class="tamanhos">A4</p>
         </b>
         <b>
            <p class="tamanhos">A3</p>
         </b>
         <b>
            <p class="tamanhos">A2</p>
         </b>
      </div>
#

it was returned by that console.log(document.getElementById("your_select_id"))

bleak bobcat
#

The second one I guess ? As you can see that's not a select, just a div and some bold paragraphs

wild thunder
#

oh, jesus

#

i guess i found

#

the error

#

i'll check

#

fml

#

sorry guys, found the error

somehow i had a div with the exact same name and it was not pointing to double id names

bleak bobcat
#

:p

#

When in doubt, log

wild thunder
#

i'll keep that in mind, thank you @bleak bobcat

#

now i'll get my breakfast, i would not eat without solving this

atomic zinc
#

Hello all. Any recommendations for a tutorial/course for a beginner who wants to study HTML CSS JavaScript

wild thunder
#

the mozilla documentation helps a lot, i'm learning js too

#

very well explained

livid scaffold
#

@atomic zinc are you a complete beginner

native tide
#

Codecademy

atomic zinc
#

@livid scaffold yes

native tide
#

Got got an email confirmation functionality done with Flask... this is awesome

coral raven
#

Great!

livid scaffold
atomic zinc
#

thanks

livid scaffold
#

these are basic

native tide
#
<a href='/verify_account/{{ token }}'> Click here to verify </a>```
#

How can I set the <a> link to the /verify_account/<token> route I have in flask?

#

Nevermind - I got it. Here's for anyone who's interested:

<a href={{ url_for('verify_account', token=token) }} > Click here to verify </a>

#

But I do have a problem.

Say I was in gmail, and I pressed the link, it would send me to /verify_account/{{token}}/ I'm currently running on localhost, and the link doesn't include it (so it doesn't work).

Is there any way for it to redirect to http://127.0.0.1:5000/verify_account/{{token}}/

glossy arrow
#

Can I ask about javascript here?

mellow tide
#

@glossy arrow You can, but there is no guarentee you will get an answer considering this is a Python server

glossy arrow
#

Ok, thanks

plucky mason
#

Learning Django...
I have a form that I have submitted data through from my index.html. I want the results of the form to show up on my result.html. As of right now, everything shows up right including the checkboxes I checked from my form... everything except my radio buttons. They show up, but they show up with the name rather than the value.

<div id="married_block">
  <p>Married?</p>
  <input
    type="radio"
    id="married_yes"
    name="married"
    value="Yes"
  />
  <label for="married_yes">Yes</label><br />
  <input
    type="radio"
    id="married_no"
    name="married"
    value="No"
  />
<label for="married_no">No</label><br />

How do I get the result.html to show Yes or No instead of married or child?

EDIT: Turns out there was absolutely nothing wrong... when in doubt: restart server.py, refresh browser

#

result.html:

<p>Married: {{married}}</p>
<p>Children: {{child}}</p>
#

views.py:

user_form_married = request.POST['married']
user_form_child = request.POST['child']
short sierra
#

views.py

def create(request):
    if request==Post:
        form =NewPost(request.POST or None)
        if form.is_valid():
            form.save()
            return redirect('homepage')
    else:
        form=NewPost()
        return render(request,'blog/create.html',{'form':form}) ```
``` forms.py ```

class NewPost(forms.Form):
title=forms.CharField(label='Your name',max_length=50 )
content=forms.CharField(label='Your name',max_length=300) ```
its not working anyhelp

craggy orchid
#

I want to be able to make dashboard for a discord.py bot, but I can't find any templates or whatever. What is a good suggestion?

elfin gyro
#

What is the best way to make html fully responsive on mobile devices using css?

acoustic oyster
#

@craggy orchid I created my own using React, any JS framework could get this set up very quickly. If you just want a static sort, you can google "free dashboard templates" and should get a nice selection

craggy orchid
#

Ok

acoustic oyster
#

@elfin gyro I often use bootstrap since it handles quite a lot of the responsiveness. Other than that, I like to take the "mobile first" approach. This is designing a site with mobile in mind, then making it work for desktop, not the other way around.

With that said, if designed well, it can take just a few media queries to make it work.

I'll send a picture of what a REALLY particular component required for css to work on desktop

#

this needs to be refactored, but this is the solution I needed to get a really particular banner to work on multiple devices

#

I would say the best way is to keep it simple, design with mobile in mind, then alter things where needed in media queries. If using a framework, the mobile side can be an after thought (although it should not be) if you are able to fit everything into the framework.

i.e for bootstrap

<div class="container-fluid">
  <div class="row">
    <div class="col">
      <h1>Stuff</h1>
    </div>
    <div class="col">
      <h1>More Stuff</h1>
    </div>
  </div>
</div>
crimson yarrow
#

hey guys

#

in flask

#

im trying to do a thing where

#

the user uploads a csv

#

i manipulate it

#

and then the user can download the manipulated csv

#

any idea on how to do this?

native monolith
#

How can I make form ( or some text box) bigger? IM working in flask and I want to see more links when I paste them

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <h1>Hello template</h1>
</head>
<body>
<form method="GET">
    <input name="text">
    <input type="submit">
</form>
</body>
</html>
native tide
#

def here(sometexthere,templatehere):
@app.route(sometexthere)
return render_template(templatehere)

#

Why does this give me Invalid syntax.

#

I'm using flask.

native monolith
#

@app.route(sometexthere) above def

native tide
#

ok thanks

jade lark
#

Anyone using FastAPI in production by chance?

mellow tide
#

@crimson yarrow so are you asking us to write this app for you? do you have code?

crimson yarrow
#

yeah i have some code ill post it

mellow tide
#

short answer is yes you can do that

crimson yarrow
#

i was more asking like a higher level overview of methodology

#

what i have going on right now it

#

an ajax for the download button

#

that sends to the flask back end the uploaded file

#

and in the back end the processing is done

native tide
#

yall ever have the query ID and session ID differ ? how strange

crimson yarrow
#

so

#

it looks something like this

mellow tide
#

wow ... i haven't heard the term "ajax" in a few years lol

crimson yarrow
#
$('#dld').click(function (e) {
            e.preventDefault()
            $.ajax({
                type: 'POST',
                url: '/raw_data_download',
                data: new FormData($('#upload-file-form')[0]),
                contentType: false,
                processData: false,
                success: function (data) {
                    console.log(data)
                }
            });
        });
mellow tide
#

mostly because almost everyone hate XML

crimson yarrow
#
@app.route("/raw_data_download", methods=['GET', 'POST'])
def raw_data_download():
    all_files = request.files.getlist('csvfile')
    raw_df = pd.concat((pd.read_csv(f) for f in all_files))
    raw_df = raw_df.drop_duplicates()
    return send_file(raw_df.to_csv(),
                     mimetype='text/csv',
                     attachment_filename='Adjacency.csv',
                     as_attachment=True)
#

oh rly?

#

i thoguth everyone uses jquery

#

but yeah i just wanna basically send that raw_data as a csv file to the user

mellow tide
#

i can't speak for everyone, but in every job i've ever had, all the messaging is in JSON

crimson yarrow
#

like a download prompt

#

yeah

#

if i could maybe turn the csv into a json

#

and prompt a download

#

basically i just want them to be able to download that raw_df

mellow tide
#

so, any time i've ever done that, it required a place to put the processed file (S3 bucket, or static asset place in my local web server) that I then point to ... i've not done a pure stream of a CSV or anything for that matter

native tide
#

How can I have a variable in a function transfer to another in flask

flint breach
#

Ajax doesnt really mean xml

acoustic oyster
#

How can I have a variable in a function transfer to another in flask
you can pass it as an argument, or find a different way to do it haha

native tide
#

Is there something i can use that can make making a forum website easier?

jade lark
#

That's Python not that I know of.

#

If you really wanted to in Python could just use Django and that would be fast af to make it.

#

else I would use MyBB or something along those lines

native tide
#

Am using flask and html css for front end.

acoustic oyster
#

django is kind of made for forum/blog style sites. I feel that your question is a little too vague

#

To make things easier: use a css framework.

Follow tutorials. Django is set up out of the box to make a forum/blog site

native tide
#

I already started with flask, am finishing up the home page and i need to know how to make forums.

#

@acoustic oyster

acoustic oyster
#

yeah, I understand I do not use flask.

Do you have a more specific question though?

#

if you just want to create an entire forum, the I recommend following a tutorial

native tide
#

Is there something that is built upon flask that i can use to make forums easily?

acoustic oyster
#

Their default tutorial covers a blog site, which is very similar to a forum. I believe you would need to add some custom stuff for replies and what-not, but this is a good start.

creating a post would be the first step.

I would consider adding replies/comments to be the next/more advanced step in working with flask

native tide
#

Ok thanks.

jade lark
#

You could look at Corey Schafer as well for Flask tutorials.

#

Not exactly like a blog. It does have login, logout and posting features for all users though. Series is here: https://www.youtube.com/watch?v=MwZwr5Tvyxo&list=PL-osiE80TeTs4UjLw5MM6OjgkjFeUxCYH

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://githu...

▶ Play video
native tide
#

Ok thanks.

native tide
#

This is a really dumb question most likely, but i can't figure out how to make my stuff not resize all weird when i change the size of the window in chrome

acoustic oyster
#

like your html?

You would need to just set the size using css/style

i.e

<img class="my-image" src="this_image.jpg">

and in css

.my_image{
  width: 300px;
}

something like this

native tide
#

@native tide
some Internet explorers allow the use of vw

#

so for example

#

if you would like the text to be the same size as you zoom in

#

you can do font-size: 3vw;

#

otherwise

#

just search up, Making my site responsive

native tide
#

Thanks @native tide

#

no problem

normal blade
#

hey guys, i wanted to deploy my django app using heroku (first time deploying a web app).. i looked at the documentation and watched a couple of videos, but some places say that i need AWS if i want to allow the users for uploading pictures. (it is a blog app).. what do ya'll suggest?

snow dragon
#

Where will the images be stored and/or hosted?

#

AFAIK heroku does not offer a block storage solution

normal blade
#

i honestly dont know a lot, i thought i could do everything with heroku

snow dragon
#

I'm not an expert on Heroku but I'm pretty sure they don't offer block storage. You'll need somewhere to store your images and host them.

vestal hound
#

if you want to upload images you probz want something like S3

normal blade
#

hmm.. so i cam store like blog posts on it?

vestal hound
#

hmm.. so i cam store like blog posts on it?
@normal blade you can use a database for that

snow dragon
#

Yes S3 would be AWS's block storage offering.

vestal hound
#

which Heroku does have

normal blade
#

great

#

do i need to host my sql separately?

vestal hound
#

well

snow dragon
vestal hound
#

Heroku has Postgres too

normal blade
#

oh greato

snow dragon
#

IMHO though if you're using AWS for S3, I'd probably architect the whole thing on AWS. Getting Heroku and S3 to authenticate will be no fun and it won't be nearly as performant as if everything is on AWS.

#

AWS has a managed DB offering too (Aurora)

normal blade
#

hmm, does AWS have a free tier for students in Canada?

snow dragon
#

and it is much better at scale than heroku (although that may not be an issue)

#

AWS has a free tier for students, not sure about international restrictions

normal blade
#

aight perfect

#

thanks ya'll!

snow dragon
#

Free tier is global and is 750 hours of RDS and 5GB of S3

vestal hound
#

yup

#

it's basically a tradeoff between convenience and performance

#

like IMO (because that's what I'm doing now)

snow dragon
#

Yeah but I think hooking heroku into S3 means it's a tradeoff between performance and performance.

normal blade
#

haha

vestal hound
#

AWS + Heroku is still more convenient than everything on AWS

snow dragon
#

Not to mention learning heroku is not very useful in an enterprise while AWS knowledge is very useful.

normal blade
#

i was following the CoreyMS django tutorial haha, he does S3+heroku as one option

snow dragon
#

@vestal hound I disagree whole heartedly. AWS architecture can be simple. It is challenging to get to that architecture but there are plenty of resources in this server and elsewhere to help. Heroku+AWS will always be inconvenient.

#

Then again, I don't see a need for heroku/netlify/etc. for hobbyists unless you actively don't want to learn marketable skills.

vestal hound
#

AWS + Heroku in the sense of just S3

snow dragon
#

It starts with S3, there will be something else 🙂

normal blade
#

wait so, if i just remove the pictures.. i can do everything with heroku?

snow dragon
#

Yes

normal blade
#

and then shift to fully aws once i get aws credits from my uni?

snow dragon
#

You could still have images, just make it so users have to provide you a URL instead of allowing them to upload them.

normal blade
#

huh, and heroku is free for a while eh?

snow dragon
#

I know little of heroku but yes I think so.

#

Again, if you're trying to learn AWS, why not just use AWS?

#

AWS has a free tier also

normal blade
#

because, im so sure i will exceed the limits of aws

snow dragon
#

You will be working on this for over 750 hours in a month?

normal blade
#

wait i thought that was per year lol

snow dragon
#

Even if you do, AWS is very cheap. My monthly bill for a number of hobby projects is about $1.50

normal blade
#

huh pretty sure not 750 per month

#

well, this is a startup project

snow dragon
#

750 hours per month of Linux, RHEL, or SLES t2.micro or t3.micro instance dependent on region

normal blade
#

that noice

snow dragon
#

Just make sure you use the right instance size/type the UI will confirm that it's free

#

Basically 750 hours means it's free as long as you only have one instance. 30 days * 24 hours = 720 hours

normal blade
#

uni has a incubator, i have applied.. if i get selected I'll receive a lot of aws credits (hopefully)

vestal hound
#

@vestal hound I disagree whole heartedly. AWS architecture can be simple. It is challenging to get to that architecture but there are plenty of resources in this server and elsewhere to help. Heroku+AWS will always be inconvenient.
@snow dragon it can be

#

but I don't really think the startup cost for AWS can be compared to that for Heroku

#

I just want to deploy stuff

normal blade
#

dude thats pretty decent, does the aws cost scale exponentially? my uncle pays like 2700$ a month for his company

snow dragon
#

AWS is a marketable skill, especially creating simple, maintainable architectures.

vestal hound
#

indeed it is

#

I never disputed that

snow dragon
#

@normal blade I wouldn't say it scales exponentially. A large part of your cost is how good your architects are...

normal blade
#

hmm

snow dragon
#

@vestal hound I just think if someone is a young developer, looking to learn cloud deployment. Saying that heroku is "easier" is misleading. It's potentially not the best use of time.

normal blade
#

oh well, mine gonna suck for sure lmao

vestal hound
#

it depends on what you're looking for.

#

you should tailor your level of abstraction to your needs.

snow dragon
#

Right,

looking to learn cloud deployment

#

But AWS has Lightsail, which is a very similar offering

#

Lightsail + RDS is the same level of abstraction as Heroku

normal blade
#

aight guys, thanks a lot for the help! I’ll discuss with the “cofounders” about aws vs heroku xd.. appreciate it 🙂

vestal hound
#

indeed

snow dragon
#

No problem

vestal hound
#

everything Heroku has, AWS probably has, more or less

snow dragon
#

Seems like we could use a Cloud topic

vestal hound
#

my user experience has been a fair bit better with Heroku than AWS though

#

and right now it meets my needs

#

so

snow dragon
#

@vestal hound Yep. My point exactly. I'm not saying Heroku is worthless or that you should never use it. I actually work on a hobby project that uses it. But none of the devs involved are looking to learn cloud (we all know it) and we know that the scale will remain low. I just think it's the wrong answer for young devs trying to get cloud deployment on their resume.

vestal hound
#

yeah, I would agree with that

#

AWS skills are definitely quite marketable

mellow tide
#

I certainly +1 on the cloud topic needed. Though I guess devops kind of covers deployments ¯_(ツ)_/¯

ember kayak
#

None of my style.css files are loading in flask, how do i fix this

mellow tide
#

Flask doesn't load them, your html tells your browser where to get them from

#

If I had to guess, your html is grabbing them from the wrong spot or not at all

#

@ember kayak

ember kayak
#

Hi

#

One sec

#

It is working perfectly if i just load the html file into ths website

zinc hill
#

what is the best way to create multiple user types in django?

ember kayak
#

@mellow tide

#

But once i load it in flask it breaks every thing

snow dragon
#

@zinc hill Could you use Django's built-in groups for your user types?

ember kayak
#

Would you like me to show you?

mellow tide
#

@ember kayak run the site in flask and check the page source for the <link rel... that points to your css

ember kayak
#

Then?

mellow tide
#

Well first of all, make sure it looks right

ember kayak
#

Ok, want to get in a vc(inwont be able to talk) and show you my screen?

zinc hill
#

thank you ill look into it

mellow tide
#

No, sorry. My family is sleeping.

ember kayak
#

Kk

#

One sec

remote echo
#

ctrl + f5

ember kayak
#

Me?

remote echo
#

yup

ember kayak
#

Nothing happend

mellow tide
#

So if I had to guess, you aren't including the css as a thing that flask is actually serving (e.g. static assets)

ember kayak
#

Wdym?

mellow tide
#

Google flask static assets

ember kayak
mellow tide
#

You have to serve all of your site (css included) for it to work, so do some googling and when you get stuck, we can help further

ember kayak
#

Ok

remote echo
#

@app.route('/cdn/path:filename')
def custom_static(filename):
return send_from_directory(app.config['CUSTOM_STATIC_PATH'], filename)

#

custom your path

mellow tide
#

Fwiw, hand feeding people solutions doesn't actually help them when they are learning

remote echo
#

i see

stone olive
#

Hello!!! Who have one job?

snow dragon
#

um, I have a job.

forest notch
#

lol

native tide
#

😂 😂

bronze sky
#

Hi everyone, not sure if I am posting in the correct channel but I'm dealing with an issue with virtual environments in conda (working with Flask right now). When I activate my environment, there is no parenthesis on the left that indicates what environment I'm currently in. Does anyone know how to fix this?

forest star
#

hlo everyone i am new in this community and i need to design a web so plz tell me the process from beginning

#

???

native tide
#

@forest star learn HTML, learn css, learn js (optional)

#

what does it mean when i run py manage.py runserver

#

and see this Watching for file changes with StatReloader Performing system checks... the entire time.

short sierra
#

views.py

def create(request):
    if request==Post:
        form =NewPost(request.POST or None)
        if form.is_valid():
            form.save()
            return redirect('homepage')
    else:
        form=NewPost()
        return render(request,'blog/create.html',{'form':form}) ```
``` forms.py ```

class NewPost(forms.Form):
title=forms.CharField(label='Your name',max_length=50 )
content=forms.CharField(label='Your name',max_length=300) ```
its not working anyhelp

native tide
#

With flask is there any way I can render a new template onto the page, without changing the URL?

native tide
#

@native tide it's the debug function

#

okey

#

@native tide depends

#

So could I have a render_template in an if statement?

bleak bobcat
#

Sure, why not

native tide
#

yes

#

whenever you return a statement it will only execute that

signal kraken
#

!close

native tide
#

?

#

wrong channel

#

Yeah you can render_templates more than once in a URL

native tide
#

Has anyone used bootstrap with WTF Forms

brave elbow
#

Can someone help? Im working with python and flask. I want my layout template to have a conditional that depends on the current url/route. for exampe, my layout template has tabs, and I want the tab that is for the current page to be a different color or 'active'. How can i do this?

jade lark
#

@brave elbow Have a conditional for rendering it. Have a tag for it. for example in a dict use something like "current_page": "home"

#

and then on the Jinja template have {% if item["current_page"] == 'home' %}active class here{% endif %}

#

have it inside the class="{jina2stuffhere}"

brave elbow
#

Thank you very much!

jade lark
#

You're welcome! Hope that helps

languid thunder
elfin gyro
#

@plucky holly I'm little confused. Did you call that function, like, anywhere in the code because I just can not see it...

#

Ok, do you get the program to print "Listening on localhost..."

#

@plucky holly

#

I mean, could you try it again and tell me? I mean if it doesn't I think what might be the problem but I am not an expert using web sockets...

#

Maybe host it on local network?

#

Just for testing.

keen acorn
#

Hey I am trying to learn about how to make a flask web application using sessions for login and I am really perplexed about how it is storing its data
For example I am currently using Flask_Discord to authenticate using Discord
When I first ran to program the scopes were configured so it would get my guilds data
Then I changed the scopes to only have my identity
But the Flask app still has my guilds data cached somewhere, and what is driving me nuts is that i have no idea where

#

This is the code I somewhat modified but started with

#

This is the code I somewhat modified but started with
So like in this part

#

If you leave the discord.create_session() empty the scope that Discord will ask automatically includes 'guilds'
After I ran it once and gave it that information I specified that I only wanted 'identity'

#

It still returns me this though when I access the guids section in the webserver