#web-development

2 messages · Page 55 of 1

zealous siren
#

I GAVE THE LINK

supple loom
#

okay

#

installing that

#

thanks

#

64 only i need right?

#

not both

light willow
#

@zealous siren I have a back-end architecture question for web. Is this the correct place to ask it?

zealous siren
#

sure be only 64

#

if that doesn't work

#

install 32

#

j sure?

supple loom
#

both installed after uninstalling what i had ...got the same thing again and now getting the same error

light willow
#

j sure?
@zealous siren

Ok. I asked in the help channel but no one responded, so I'll paste it here

#

Ok it was moved to dormant

#

I'll just paste it here.

I'm working with time-series data and need to use Python libraries in the process (talib). The client-side is VueJS and makes requests to a GraphQL server (Hasura) which is connected to timescaleDB.

So VueJS <---> Hasura <--> timescaleDB.

I will be creating Python microservices to run analytics on the timeseries data in timescaleDB (which is SQL btw).

When the client makes simple requests for raw data (eg. to view a chart) the request goes from Vue to Hasura to timescaleDB.

However when the user makes a complex request, it needs to go to the Python service that performs analysis on the timeseries data and returns the response.

I want to know where the Python microservices fit. Do I have to connect them to Hasura so that the complex query is sent to Hasura by the user and then is sent off to the Python service which then connects to timescaleDB independently, or does the Python service also connect to Hasura via GraphQL?

zealous siren
#

So I’m not familiar with those apps so my questions will be general

#

Most of time queries will go to Hasara for processing but occasionally they are too complex and need to be dealt with by python before Hasara?

light willow
#

Most of time queries will go to Hasara for processing but occasionally they are too complex and need to be dealt with by python before Hasara?

Yes

zealous siren
#

so you need a router service

#

and likely processing service

#

so Router determines straight to Hasara or not, and processing service that will run the code then pass it to Hasara service

#

in theory, you should have query service because multiple microservices, same database is frowned upon but baby steps

#

So VueJS -> Router --maybe--> Processing (which will they reach into DB) -> Hasara

#

Router/Processing could be same as well

#

Depends on how deep you want to go

cold anchor
#

in the past when I've had to do complex queries over time series data, I create a separate "summary" table and run the expensive queries offline so the user experience is snappy

#

that's a very common practice

light willow
#

in the past when I've had to do complex queries over time series data, I create a separate "summary" table and run the expensive queries offline so the user experience is snappy

Yes, preprocessing and saving results for reuse?

#

@zealous siren ok thanks. I was wondering how I could make Python sit between Hasura and Timescale

cold anchor
#

yes, since it's a time series data (which are almost always immutable data), it's safe to store the results of the expensive queries as the "truth" instead of running expensive queries at user-experience time

light willow
#

Essentially I'm hoping to have a single GraphQL endpoint for the user.

#

yes, since it's a time series data (which are almost always immutable data), it's safe to store the results of the expensive queries as the "truth" instead of running expensive queries at user-experience time

Ok yes I thought so. I guess my next question is how do you determine when to draw the line on storing stuff?

#

So, for example stuff I'd use a lot like an indicator, say normalized average true range, would be saved as another column along with the time-series data

#

Or you're saying to separate the summary data from the raw stuff

cold anchor
#

yes, separate the summary data from the raw data

zealous siren
#

sure, caching is great but Rome wasn't built in a day

light willow
#

Ok thanks guys this was very helpful. Will come back when I have Python specific questions. Sorry if this was a bit off-topic

cold anchor
#

when deciding to separate, I usually ask "does this data power a page in my app for the user/customer?" and "does the query consistently take longer and a couple seconds and tax the database or data API service?" - if both are yes, I make an event summary for the query

#

this isn't cacheing, it's running long queries offline and saving the results

zealous siren
#

Sure but if queries are not commonly repeated, caching results may not make sense

#

and sometimes it's cheaper to throw some more hardware then overhead of storing and retrieving cache results 😄

cold anchor
#

if the answer to "does this data power a page in my app for the user/customer?" is yes, the queries are commonly repeated

#

again, not a cache lol, a separate table of data

wild thunder
#

i'm here

cold anchor
#

(continuing from #help-grapes ) ok let's talk about context locals

wild thunder
#

alright

cold anchor
#

when flask runs, there are different levels of a "global" variable that persist

#

there's the normal stuff, things like variables inside functions, the python language handles that

#

but when we start our flask app, we also assign a config to that app, which are things like the database URL, the debug flag, etc. that live on the context of the "app"

#

these variables persist inside the context of the app, and are available when flask runs your code

light willow
#

It's not letting me use emoji reactions wtf. Lol

cold anchor
#

from flask import current_app

wild thunder
#

but when we start our flask app, we also assign a config to that app, which are things like the database URL, the debug flag, etc. that live on the context of the "app"
@cold anchor it's related to python app.config['SQLALCHEMY_DATABASE_URI'] ?

cold anchor
#

exactly that

#

these variables are shared across all server processes, threads and requests being handled

#

as such it's imperative that you don't modify them after the app starts

light willow
#

Sure but if queries are not commonly repeated, caching results may not make sense

He's saying to make a separate data table for summary data in addition to the raw data.

wild thunder
#

it have to be static as long as the app runs?

cold anchor
#

I don't think there's anything stopping you from changing them while the app runs, but it's a bad idea, because it's shared across multiple threads

#

(it can't be shared across multiple processes, because they can't share variables in the same way)

light willow
#

when deciding to separate, I usually ask "does this data power a page in my app for the user/customer?" and "does the query consistently take longer and a couple seconds and tax the database or data API service?" - if both are yes, I make an event summary for the query

This is very helpful. Thank you!

wild thunder
#

hmm

cold anchor
wild thunder
#

but like, my concern is: how does the program manage multiple connections

#

like this

#

made on paint with absolute painting skills

cold anchor
#

beautiful

wild thunder
#

hahaha 😛

#

it's with threading?

cold anchor
#

so when a request comes in, the thread handling it creates a new request and session context to handle the connecting user

wild thunder
#

do i have to make it, or flask.app does it automatically

#

?

cold anchor
#

flask does it for you

wild thunder
#

oh

cold anchor
#

that's also a big discussion, we can cover that later

wild thunder
#

so it's half way to make an online game

#

it already plugs people on "different ports"

#

idk if it's the port or just the ip that changes, the ip makes more sense

cold anchor
#

sort of, again that's a little out of scope of this for now

#

that's closer to the operating system than we need to care about

wild thunder
#

but that already explained a lot

i mean, in my head, when a user was logged in, and another one logs in it could cause trouble if i did not handle that on code

cold anchor
#

anyway back to this idea of a "request context": when flask gets a new request, it creates a new context for you to handle global variables for that request flask.g

#

that's where flask.g and flask.session come to the rescue

#

they're entirely created and destroyed within the lifetime of a single request

#

so if user A and user B send a request at the same time, they still won't overlap because they're two different requests

wild thunder
#

ohh

#

got it

cold anchor
#

does that answer your question?

wild thunder
#

yes

#

i was thinking this happens

#

but it's separated

cold anchor
#

yes, it's separated

wild thunder
cold anchor
#

request contexts never overlap

#

yes, like that

wild thunder
#

alright, that solves the question

#

@cold anchor thank you man, saved the day

#

i was going nuts

#

idk the words to search for it online

cold anchor
#

those links I posted about the request and app contexts are good reads

wild thunder
#

i'll read them now

calm heath
#

hi everyone.. I'm not sure what the appropriate channel would be to ask a question about tweepy... any suggestions?

signal yoke
#

I want to host a server on my machine. All I need to do is to forward one port and write

server_socket.bind(('0.0.0.0', forwarded_port))```
?
or should the IP be the external router ip
queen bough
#

@signal yoke If you only want to access it locally (i.e. from other devices connected to the same network) then 0.0.0.0 is fine, otherwise it has to be your external IP.

oblique hemlock
#

Someone suggests me a book for django

fiery tapir
#

With selenium do I need to actually link to where I have the Firefox driver? It seems to be working without actually linking it like so
firefox_browser = webdriver.Firefox()
but every tutorial i've read and watched so far they link to the drivers executable.

quasi ridge
#

hey if it's working, wassa problem

#

my hunch is that it looks for it in "standard" places if you don't tell it exactly where to look, and yours is indeed in a standard place

fiery tapir
#

yeah, whenever i tried to do it as
firefox_browser = webdriver.Firefox('./geckodriver.exe')

#

it wouldn't work at all

#

said it couldn't find the file

#

when it was in the same folder

quasi ridge
#

well ... this is like one of the biggest annoyances ... . doesn't mean what you think it means

#

it means "the current working directory of the python process", but not neccesarily "the directory this file is in"

quasi hawk
#

anyone have experience with web crawlers?

pseudo tapir
#

What's the best way to go about changing the django admin page? I'd like to extend my base.html including the header and everything

solar hatch
#

Who use Vue or react with Django/flask

#

Is use js framework with Django/flask good choice

#

??

pseudo tapir
#

I use Vue with Django

solar hatch
#

Oh

#

I am learning Vue

#

And i am kinda lost

#

@pseudo tapir what does vue do when your using Django

pseudo tapir
#

vue is frontend

solar hatch
#

Ok

native tide
#

What is it like to use a JavaScript framework with Python backend? Like, do you still render templates at all?

lucid marsh
#

I'm having a problem with Django redirecting constantly

#

just throwing 302's at me

native tide
#

Like an infinite loop of 302?

#

Look for somewhere in youre control flow where you're calling a redirect where the condition always true.

#
@mixin grid-row-span($start, $end) {
    grid-row-start: $start;
    grid-row-end: $end;
}

@mixin grid-col-span($start, $end) {
    grid-column-start: $start;
    grid-column-end: $end;
}

it sassy

native tide
#

haha I just realized I didnt need to write that mixin, they already have a property that combines those two.

signal yoke
#

@queen bough are you sure? doesn't 0.0.0.0 means "all traffic"?

#

I assume on the client site it has to be the external ip

blazing jetty
#
    flash(error_handler[error])
    sleep(3)
    return redirect('redir')```
#

It's not showing the msg box :/

#

I would like to redirect user to another site and let him know that

#

flask

native tide
#

I think that 0.0.0.0 means broadcasting on the local network. So whatever network its on, it means its serving to every localhost on the network? I think thats how it works anyway.

ancient hill
#

hi I'm new hear i now somethings about Django and rest but i need big picture of what i need to learn to launch full flagged site with it like online store with it

supple loom
#

someone help me out with this.....i have installed vs redist 14.25 and build tools from visual studio installer...it still gives the same error

native tide
#

Anyone using vue flask ?

cloud path
#

guys how can i write on this button?

#

{{ form.submit(class="mtr-btn signin") }}

#

it appears empty

native tide
#

Flask or django ?

cloud path
#

i'm using flask but into the form i already writed onto

#

like that submit = SubmitField('Accedi')

native tide
#

if thats flask wtf submit =

#

Oh ok

cloud path
#

but if i put the style through the "class" keyword

#

the word disappears

#

it shows the word just without any style

native tide
#

it should not amtter u are just adding the class do you have anything related to the text in css to that style ?

cloud path
#

mm i have to check because the template is pre-made free usage

#

but if i remove the class

#

the word appears good onto the button

#

i'm uploading a screenshot of the button but it's a bit slow

native tide
#

You dont have to remove class

#

is there anything

#

inside that class

#

that is related

#

to text

#

it can cause trouble

#

keep the background

#

color etc

#

but remove everything that is related to text inside that class

blazing jetty
#

why

#

it uses local address

cold anchor
#

well it can't attach to another computer's IP address

#

it has to attach to its own

blazing jetty
#

so it should be like that?

#

It says bad gateway when I go to the site

cold anchor
#

what is saying bad gateway? gunicorn? your app server (flask? django?) your reverse proxy (nginx? apache?) or something else?

blazing jetty
#

nginx

#

what ever

#

I've tried 3 tutorials already and haven't got anything working

#

ima go back to the first one..

cold anchor
#

what's your nginx config look like?

#

and is your application server binding to 0.0.0.0? (I've found not binding to that specifically can cause problems)

queen bough
cold anchor
#

hm, so then you'd only want to bind to 0.0.0.0 when you want your app available at any IPv4 address pointing to that server, and you'd want to bind to 127.0.0.1 when you want the app available only to another process on the local machine (like nginx)

blazing jetty
#

WHY

#

WHY

#

fuckin

#

I hate configuration files, why can't they be simple and they have to be in 10 different placesAAAAA

#

I tried to freakin reinstall apache2 and still doesn't work

#

it worked the first time

cold anchor
#

already in use

blazing jetty
#

I can read but what is in use

#

I did service apache2 stop

cold anchor
#

lsof -i:80

blazing jetty
#

nginx

#

ffs

cold anchor
#

what's the nginx config got for forwarding rules?

blazing jetty
#

it had my server's ip

#

It still doesn't work, I did systemctl stop nginx

#

can i restart this server so it doesn't run these

cold anchor
#

I'm not super familiar with these commands, but as long as it doesn't have a "spin this process back up when the server restarts" mechanism that should work

blazing jetty
#

gg

#

still doesn't work

#

..

#

now it's missing some conf file

#

noice

inner latch
#

Any good courses/resources out there on Web Development with a particular focus on Python?

native tide
#
input:checked + .content #grid {
    display: grid;
}

You really dont need JS anymore...

haughty saffron
#

I've got this script that's meant to recolour all of the elements with the ID, but i can't even get it it to fire

document.onload = function () {
  console.log("document loaded!")
  var coll = document.getElementsByTagName('div');
  var arr = [];
  for(var i = 0; i < coll.length; i++) arr.push(coll[i]);
  arr.forEach((elem) => {
    let rgb_elem = document.getElementById(`rgb ${elem.id}`)
    let rgb = hexToRgb(elem.style.backgroundColor)
    rgb_elem.textContent = `RGB: (<span style='color: rgb(${rgb.r}, 0, 0)'>${rgb.r}</span>,<span style='color: rgb(0, ${rgb.b}, 0)'>${rgb.b}</span>,<span style='color: rgb(0, 0, ${rgb.g})'>${rgb.g}</span>,`
  })
}

I am importing it from a .js file via <link>. Do i need it to be a local script?

#

apologies if its bad js i don't use it that much

brisk ravine
#

anyone know how to get the public ip of the user in Django???

native tide
#

I'm not the best at JS either but

document.getElementById(`rgb ${elem.id}`)

Is that valid? Aren't you allowed to have spaces in ids? I find that rgb-whatever would be more common. That might not be the problem....

haughty saffron
#
document.addEventListener('DOMContentLoaded', function () {
  console.log("document loaded!")
  var coll = document.getElementsByTagName('div');
  var arr = [];
  for (var i = 0; i < coll.length; i++) arr.push(coll[i]);
  arr.forEach((elem) => {
    let rgb_elem = document.getElementById(`rgb ${elem.id}`)
    let rgb = hexToRgb(elem.style.backgroundColor)
    rgb_elem.textContent = `RGB: (<span style='color: rgb(${rgb.r}, 0, 0)'>${rgb.r}</span>,<span style='color: rgb(0, ${rgb.b}, 0)'>${rgb.b}</span>,<span style='color: rgb(0, 0, ${rgb.g})'>${rgb.g}</span>,`
  })
})

even with this, its still not firing

#

TLS thats not the issue, but the event isn't firing

#

the rest is fine

native tide
#

I'm assuming you have it deferred at the end of the html? If so, not sure. Im pretty new to JS.

haughty saffron
#

Ill try

#

nothing

#

it doesn't seem to be loading the script at all wtf

#

even when i slap the contents in a <script> tag still nothing

native tide
#

You could try putting it directly into script tags to see if it works. Maybe its pathing isssue

#

Ah well damn

#

The other day I forgot to have a closing </script> on my <script> and it caused it to not load but its not that then.

haughty saffron
#

hang on

#
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>DragDev Studios - Branding</title>
  <meta content="" name="description">
  <meta content="width=device-width, initial-scale=1" name="viewport">

  <link href="site.webmanifest" rel="manifest">
  <link href="icon.png" rel="apple-touch-icon">
  <link href="js/main.js" rel="script">
  <!-- Place favicon.ico in the root directory -->

  <link href="css/normalize.css" rel="stylesheet">
  <link href="css/main.css" rel="stylesheet">

  <meta content="#fafafa" name="theme-color">
  <style>
    html, body {
      margin: 0;
      padding: 0;
    }
    div {
      min-width: 100%;
      margin: 0;
      padding:15px;
      min-height: 4em;
    }
  </style>
</head>
<body>
  <h1>Colours:</h1>
  <div style="background-color: #a34142" id="MemberRed">
    <h2>"Member Red"</h2>
    <ul>
      <li>Hex: <code>#a34142</code></li>
      <li id="rgb MemberRed">RGB: <i>Not calculated</i></li>
    </ul>
  </div>
  <script defer>...</script>
</body>
</html>
#

in <script>

    function hexToRgb(hex) {
      let result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex);
      return result ? {
        r: parseInt(result[1], 16),
        g: parseInt(result[2], 16),
        b: parseInt(result[3], 16)
      } : null;
    }

    document.addEventListener('DOMContentLoaded', function () {
      console.log("document loaded!")
      var coll = document.getElementsByTagName('div');
      var arr = [];
      for(var i = 0; i < coll.length; i++) arr.push(coll[i]);
      arr.forEach((elem) => {
        let rgb_elem = document.getElementById(`rgb ${elem.id}`)
        let rgb = hexToRgb(elem.style.backgroundColor)
        console.log(rgb)
        if (rgb === null) {
          alert(`unable to calculate RGB of hex ${rgb}`)
        }
        rgb_elem.textContent = `RGB: (<span style='color: rgb(${rgb.r}, 0, 0)'>${rgb.r}</span>,<span style='color: rgb(0, ${rgb.b}, 0)'>${rgb.b}</span>,<span style='color: rgb(0, 0, ${rgb.g})'>${rgb.g}</span>,`
      })
    })

    console.log("hi")
#

thats all ive got right now

versed sigil
#

looks like port 80 is already in use

#

cant you just change to higher port

native tide
#

8080 or 81 is common.

#

alternate http ports that is

#

what is in that main.js?

#

i dont see why that would matter tho

#

I would try umm removing document.addEventListener('DOMContentLoaded', function () { and then just having it at the very end so that it naturally loads the script after the content is loaded.

#

I think you can take that defer out, I think the defer keyword is for when you have the JS at the top of the file and still want it deferred. Other than that, I have no idea.

fading mason
#

so I need to make a search engine functionality on my django website which will filter the topics by the searched keyword

#

not sure how to go about it

#

actually nvm

#

I'll figure it out

blazing jetty
#

I'm getting internal server error

zealous siren
#

ok, check the error logs

blazing jetty
#

got it working thx for help

unkempt terrace
#

Hello guys,

#

and I need the AQI value

toxic marten
#

I coded with selenium, a program that register an account. But often i have problem, because sometimes there is recapcha

#

How can i prevent recapcha or other relative problems

zealous siren
#

you cant

#

that's whole point of recapcha to prevent what you are doing

cold anchor
balmy hamlet
#

I was wondering what orm tool do the majority of users here use

cold anchor
#

SQLAlchemy is my favorite

versed sigil
#

sqlalchemy

#

boom!

balmy hamlet
#

Is it easier to work with?

cold anchor
#

easier than writing you own db driver, yes

balmy hamlet
#

lmao well that too

#

I was wondering which might be easier to implement since I am trying to write a webserver using fastapi

#

I know they had some docs around it

cold anchor
#

try googling for "fastapi sqlalchemy" and see if any libraries come up or "fastapi sqlalchemy cookiecutter" to see if there are any working templates you can use

balmy hamlet
#

I am actually looking at the cookiecutter now

toxic marten
#

that's whole point of recapcha to prevent what you are doing
@zealous siren Yes i know that, but im searching for some way that prevent recapcha

#

i tried to modify payload of post request, i modified useragent, ip (using proxy), chrome window size, but it doesnt work

unkempt terrace
#

thanks @cold anchor

zealous siren
#

@toxic marten you see the flaw in that thinking? Hey, we implemented the thing to stop you so how do I bypass my TOS violating behavior

#

So to end this conversation

#

!rule5

pseudo tapir
#

I've never done anything like this, and I've read their docs and don't think i understand exactly what I'm to do lol

zealous siren
#

Is that for building or testing?

pseudo tapir
#

I mainly want their docs, but I haven't looked into the design thing much

zealous siren
#

That looks like it’s API prototyped

#

So it’s for design and building

#

Like early design

pseudo tapir
zealous siren
#

This looks like it’s not for building the APIs

#

Like writing the actual code for APIs

pseudo tapir
#

I see, so does this question not belong here? I'm just not sure how to get those docs myself

zealous siren
#

So build API in whatever language you want

#

Do you want to build APIs?

pseudo tapir
#

Yes

zealous siren
#

Python?

pseudo tapir
#

Yep, Django

zealous siren
#

No

#

Yes

pseudo tapir
#

What?

zealous siren
#

Is this brand new site?

pseudo tapir
#

Not really

zealous siren
#

Don’t build API Django unless it’s something tiny or you already have

#

FastAPI for building APIs

pseudo tapir
#

I'd like the site to all be in Django, one project, thanks for the suggestion though 😄

zealous siren
#

My SRE side wants to hurt you

#

But carry on

native tide
#

I want to create a project called POLLSTER that will have one app called POLLS. I am following these steps but I am getting confused.

  1. Create a new folder called POLLSTER – this will be the name of the project.
  2. Inside of POLLSTER folder, run python -m venv env, which will create a virtual environment folder called ENV within the POLLSTER folder.
  3. Inside of \POLLSTER\ENV\ folder run activate to activate the virtual environment.
  4. Inside of POLLSTER folder run python -m pip install Django (if the environment is activated, does it matter where this command is run?).

I’ve followed the above instructions from the official Django website and I have my project folder (POLLSTER) created but now the instructions are telling me to run django-admin startproject <projectname>. My issue is that this will create a project (POLLSTER) folder, which I have already done.

Correct me if I am wrong but the idea is to install Django inside of a virtual environment, and to have the virtual environment folder to be within my project folder. So if I’ve already created the project folder, why is the django-admin startproject <projectname> making another project folder?

cerulean vapor
#

OK, so here's what's going on

#
  • There's your outermost folder, which contains your main project directory and your venv directory
native tide
#

ok so what should i call that?

#

i guess not pollster?

cerulean vapor
#
  • The project directory will have in it one or more Django sites created by Django itself
#

Your outermost folder could be called pollster-project

native tide
#

ok got it

cerulean vapor
#

The folder for django-admin startproject could just be pollster

#

and the app within Django could just be called polls

#

the virtual environment you can just call env

native tide
#

ok makes sense

#

i am gonna try now. i will send a bat signal if any problems arise

cerulean vapor
#

OK

native tide
#

ok does this look good @cerulean vapor ?

cerulean vapor
#

That's about what I expected

native tide
#

PHEW

cerulean vapor
#

So now when you open pollster-project in VS Code, for instance, it'll autodetect env as the environment for it

native tide
#

it's just confusing that it makes a folder called POLLSTER within the POLLSTER folder lol

cerulean vapor
#

This is one of the reasons I don't really recommend Django to people as their first web framework; it can get really unwiedly if they don't know that it's like this

#

It's designed like this because it assumes you may want to have more than one app sharing the same site configuration

native tide
#

yea i hear that. although i have lots of coding experience so i really just have to get over these first few bumps. the code itself won't be an issue

cerulean vapor
#

and honestly the toolset it provides you with is really powerful

native tide
#

yeah i hear it's 'batteries included' compared to flask

#

they give you everything you need for a serious enterprise application

#

here it is in vscode, if anyone cares 😛

native tide
#

if the name of my app is polls , then visiting the 'polls/' url would mean that the pattern being sent to urls.py is simply ''
.... right?

#

(an empty string)

onyx crane
#

can anyone point me a good ressource for the whole slug topic in django? I just can't get my head around it and the examples or often so specific that i can't transfer it to my personal project ....

dm or @me pls. Im heading to sleep

quasi ridge
#

huh, never heard of "slugs"

leaden lantern
#

How can i use aiohttp for Image Scraping

uncut glacier
#

Anyone with google app engine experience able to help me with a problem? I'm trying to restrict access to certain URLs so they can only come from within my application (cloud tasks to be precise). With python 2's app.yaml I could do this with login: admin on those URLs but I cant find an equivalent with python 3. Any advice?

brazen iron
#

hi guys how can i try to make telegram bot and import telegram but dont know how to get image from user?

#

any one can help me ?

harsh flare
#

Can anyone help why I can't use a list iteration in this js script in my html using flask?

#
<script>
            $(function() {
            var cfg = {
                pieceTheme: 'https://koblenski.github.io/javascript/chessboardjs-0.3.0/img/chesspieces/wikipedia/{piece}.png',
                position: 'start'
            };
            var board = ChessBoard('myBoard', cfg);
            var game = new Chess();
            
            // 1. Load a PGN into the game
            var pgn = {{details[0]|tojson}};
            game.load_pgn(pgn);
            $('#pgn5').html(pgn);
            // 2. Get the full move history
            var history = game.history();
            game.reset();
            var i = 0;
            // 3. If Next button clicked, move forward one
            $('#nextBtn5').on('click', function() {
                game.move(history[i]);
                board.position(game.fen());
                i += 1;
                if (i > history.length) {
                    i = history.length;
                }
                });  
            });  
  </script>
```
#

var pgn = {{details[0]|tojson}}; is where it seems to break...

onyx crane
#

Django
I know that there is the prepopulated_field in the django admin panel.
This seems like a great way of populating slugs.

How can i generate a slug when the object is created from a form ?
Can i somehow do stuff like : Form Input 1 = slugField ?

scenic cave
#

Does somebody know how to get data from HTML forms using Python?

#

Pin @ me if you know how pls

onyx crane
#

wdym by "get data" ?

#

let user create model objects through a form ?

scenic cave
#

I mean

#

Like a box with text

#

And when you press submit the text goes to the server

onyx crane
jagged hemlock
#

Has anybody ever parsed RSS 2.0 XML, because I am a bit stuck on content:encode...

solar hatch
#

flask vs django

onyx crane
#

bit more context ?

solar hatch
#

what would learn

#

you

#

i want to make a chat app

#

@onyx crane

onyx crane
#

depends on what you want to achieve / build

Another user here stated that with flask you learn a lot more of the whole web things because you do most of the stuff by yourself.
Django provides so much functionality that you just go with so much without apreciating / learning the things in the background.

If youre getting really frisky with your stuff flask gives you more freedom, even though i can't define the limits of django when it comes to flexibility.

For some really simple projects and display applications django might be an overkill

#

I could imagine a chat app not being the easiest starter project ... with that message handling and stuff.
Maybe theres a good tutorial online though? Then just stick to that :D

tender seal
#

hi guys I'm trying to connect my raspberry pi gpio with google assistant through ifttt, I have a trouble in establishing a connection between my Raspberry pi and ifttt, I'm running a flask server in raspberry pi

#

can anyone help me

feral minnow
#

What's up guys so i wanna ask you... I see when people work on some website projects or anything else they have a specifc file for things so data bases in this file view in the view file so im working on a website project rn and I wanna know how they do that and how they link the files together ?

cold anchor
#

what do you mean? can you clarify that a bit more?

feral minnow
#

Yup give me a sec

#

so what I mean is they don't put everything in one file

cold anchor
#

for which framework? a framework like django has module separation built in

#

but you need to do it yourself for something like flask for fastapi

feral minnow
#

oh

#

the repo I just shared use django

#

but what about flask because im working with flask rn?

cold anchor
feral minnow
#

cool

#

but I didn't understand how i can do it myself?

#

because if I made different flask files everyone will be a single website

cold anchor
#

make a new file and put some functions or classes in there, then import it at from myapp.utils import get_user_agent_header for example from maybe a view file

feral minnow
#

ohhhh

#

So i make sepreate files then I import them in one file if that what you mean

cold anchor
#

yeah, into the relevant file

feral minnow
#

oh actually I don't know how they do it

cold anchor
#

what specifically is confusing you?

feral minnow
#

I don't know how to link them together or from myapp.utils import get_user_agent_header idk how to use this if you can explain it or give a link for someone else expalin it,I will appreiate that

cold anchor
feral minnow
#

oh I will check it out actually this thing was confusing me for a along time thanks

dull solar
#

I'm trying to integrate some python scripts into my web app, but I think I'm misunderstanding certain fundamentals.

I'm getting the following error:

ERROR 2020-04-24 15:12:24,358 signal 8 140184647079744 Signal handler <bound method DjangoFixup.on_import_modules of <celery.fixups.django.DjangoFixup object at 0x7f7f47457fd0>> raised: DatabaseError("Execution failed on sql 'SELECT * FROM Profiles': no such table: Profiles")

It's referring to this line of code:

    if profiles is None:
        profiles = pd.read_sql_query("SELECT * FROM Profiles", conn_mp)

The table and database doesn't exist yet, but why am I getting the error if I'm not trying to run the script yet?

All I did was save and build it, and it's throwing the error.

native tide
#

I have allowed my templates to grow so complex and numerous with poorly named files that don't match that I want to cry (not reall) thinking about what a mess it is.

#

The problem is that when I made the templates, I was using them in one place.

#

But over time the need for the same content to be plugged all over resulted in them being everywhere with the original names that in the end dont reflect entirely what is on the template. So many templates with similar names.

#

Its bad.

#

I will never make this mistake again though

stark mauve
#

Hi all

#

What are the most common options for mySQL databases to deploy a flask application with?

#

Is an sqlite database good enough for a production application?

#

Thank you.

native tide
#

An sqlite database isnt really a database at all. It's more... the sort of thing you use in a development environment for simplicity. No one can actually connect to it, which people need to do to use a database.

#

I use a postgres database and am not that familiar withg mySQL but its fairly common.

stark mauve
#

by mySQL I meant any database that isn't noSQL, sorry

#

so I guess postgres could count

native tide
#

right, well I use postgres and there is a free tier postgres addon to heroku if you want to pracitce with a free production level set up

stark mauve
#

oh ok thanks

native tide
#

Hmm, anyone here well versed in Django?
I have a problem with setting up Postgres with it, but the Django server is p. dead atm, & Stackoverflow doesn't have any problems/answers to my specific issue, apparently

onyx crane
#

nope sorry :'D

#

sliding in with my own question though:
Django:
Whats the default way of populating fields that are not supposed to be filled in by the user ?
Example: Field A is half the value of Field B + some other calculations.

unkempt snow
#

Anyone here is using Seleniumwire?

cold socket
#

Hey all, I have a project that has a Flask backend w/ Selenium and a React front end. Everything seems to work fine locally. I was wondering if anyone knows of a good tutorial on how to deploy this project to a production server (Ubuntu)?

toxic marten
#

How can i login and register on instagram using requests? Someone can explain me just basics

rich plaza
cloud path
#

guys, this tells me 'list object has no attribute items'

#
    ffriends = Friends.query.filter_by(account_owner=current_user.id).all()
    friends = []
    for item in ffriends.items:
        friend = Account.query.filter_by(id=item.friends_id).first()
        friends.append(friend)
    posts = []
    for friend in friends:
        post_ = Post.query.filter_by(owner=friend.id)
        posts.append(post_)
    return render_template('index-2.html')```
#

am i doing something wrong?

cold socket
#

@rich plaza Thanks for the article it definitely makes deployment look simple. I'm just a little confused with what qovery is doing in the background. In addition to deployment is it also hosting the project?

rich plaza
#

@rich plaza Thanks for the article it definitely makes deployment look simple. I'm just a little confused with what qovery is doing in the background. In addition to deployment is it also hosting the project?
@cold socket yes exactly, hosting, managing the database, generate SSL certificate and more than that. You can see it as the heroku of 2020 :)

cold socket
#

@rich plaza Wow that is very convenient. So it hosts everything on AWS?

#

And does it have ssh access for each application instance?

rich plaza
#

@rich plaza Wow that is very convenient. So it hosts everything on AWS?
@cold socket yes exactly. And you have the choice of the region

#

@cold socket yes exactly. And you have the choice of the region
@rich plaza why would you need SSH access ?

cold socket
#

@rich plaza My Flask app also uses selenium, so to install drivers or even monitor usage

rich plaza
#

Ah yes. Of course you can. You deploy container on Qovery. So you can install selenium and all you need

sick hedge
#

hey i serving gridfs stream from a flask server and i am not able to do seek on videos on the html side

#

it turns out this is possible on other browsers and not on chrome due to some headers and wrong status

#

so how can i handle this on flask?

tired root
#

use a video stream server as a cdn

#

@sick hedge

cold socket
#

Does my python version have to be the same on production as development for Flask application?

sick hedge
#

@tired root as to how ? the same server is also used for other purposes

tired root
#

@cold socket Does not need to be, but prepare for quirks

cold socket
#

How drastic of a difference is 3.7.4 vs 3.8

tired root
#

It's highly suggested it does

#

@sick hedge Let's first separate server software and server hardware

#

I am talking about software

#

It would be generally no issue to run a second server software on the same hardware on a different port alongside nginx/apache/whatever

#

My idea would be something like a WebRTC streaming server for this case

sick hedge
#

ahh ok

tired root
#

@cold socket You would need to look at the changelog

#

@sick hedge I am quite sure that implementing that yourself with Flask would be a very challenging task

#

so I'd look at something like antmedia

#

A second option is to use a dedicated second hardware server to handle this task

#

just point the A and AAAA record to that second IP

feral turtle
#

Good afternoon! I'm trying to understand what are VDom but I haven't found docs about the concept on the web, just docs of libraries. Do you know where I can find a library-agnostic explanation of it? Here is what I've understood so far, is it at least correct or am I wrong?

tired root
#

The Javascript objects are basically the virtual DOM

#

VDOM is an object that represents how it should be displayed, but it is not an actual thing

#

well, not in a pure browser view of things

#

The browser only knows one DOM

#

@feral turtle

sick hedge
#

its working now ty @tired root

#

206 handling i mean

feral turtle
#

@tired root Ok

#

thanks

native tide
#

Hi

#

I have to use an API

#

To use this API I need to use curl

#

How can I get the result into a var ?

#

Like, getting the output, putting it in a var named request, then parsing it using json this way req.json()

rigid laurel
#

Where are you using this api from?

#

just a python app?

#

If so, then you can use requests which will be much easier than curl

native tide
#

This is how the request looks like:

curl -X GET "https://mawaqit.net/api/2.0/mosque/search?word=lyon" -H "accept: application/json" -H "Api-Access-Token: XXXXXXXX
rigid laurel
#

Yes, thats it in the command line

#

not in python

#

is this question relate to python?

native tide
#

How can I "translate" it to Python ?

tired root
rigid laurel
#

you'd use the requests library

feral turtle
#

Better go to #unix if you use curl

native tide
#

@tired root You're a hero

rigid laurel
#
import requests 
r = requests.get("https://mawaqit.net/api/2.0/mosque/search?word=lyon", headers={"Api-Access-Token": XXXXXXXX})
r.json()
tired root
#

@rigid laurel You forgot the params

#

or well, you included them in the url

#

but its better to send them as parameters

rigid laurel
#

oh yeah - I didn't even notice they were a thing, just copy pasted - you're right

native tide
#

Hero

tired root
#

@native tide I am not. I just know how to use google

rigid laurel
#

It is generally easier for you if you just type things into google first. THere's nothing wrong with asking here, but often you'll get an answer faster by just checking google. Of course if you're struggling to understand something, have a problem you can't solve, or want a more detailed discussion, this server is the right place to ask

native tide
#

Yeah.

#

One more problem.

#

This is how the JSON results looks like

#

I want to get the "05:06"

#

I use this

#

time = json["times"][0]

#

This should work, yeah ?

#

Because I get this error: TypeError: list indices must be integers or slices, not str

queen bough
#

@native tide What's your code?

#

(Without the API key)

native tide
#
    req = requests.get("https://mawaqit.net/api/2.0/mosque/search?word=lyon", headers={"Api-Access-Token": "6"})
    json = req.json()
    mosquee = json[0]["uuid"]
    req = requests.get("https://mawaqit.net/api/2.0/mosque/search?word=" + mosquee, headers={"Api-Access-Token": ""})
    json = req.json()
    fajr = json["times"][0]
    dohr = json["times"][1]
    asr = json["times"][2]
    maghreb = json["times"][3]
    icha = json["times"][4]
    ville = json["localisation"]
queen bough
#

And it doesn't work? Try print(json) above fajr ...

native tide
#

You were right

#

The Json is empty

queen bough
#
mosquee = json[0]["uuid"]

Where does uuid come from? Why not id?

native tide
#

It does come from the first request

queen bough
#

Ah mosque/search?word= looks wrong - perhaps you meant id/uuid?

tired root
#

req = requests.get("https://mawaqit.net/api/2.0/mosque/search?word=" + mosquee, headers={"Api-Access-Token": ""})

#

Please use the params dict for that

#

This is just yucky

native tide
#

Okay, I fixed it

#

Thanks !

queen bough
#

No worries.

tired root
feral turtle
#

It's me again, I still don't understand at all what are vnodes and how they're used to render a page

feral minnow
#

Guys how I can create a box that just show up when someone click a specific lets say submit button so the user can't accsess the whole page (just the box that shows up)

#

I just found a link that explain that

rustic pebble
#

You can just add a function

#

js

#

Which creates a box

#

when the submit button is clicked

sick hedge
#

Use json.loads

muted ledge
#

who in here has created a sneaker bot?

quasi ridge
#

there's something funny about that phrase

rigid laurel
quasi ridge
#

why am I afraid to click

rigid laurel
#

Pros: you get to hear the dulcet tones of Lemon. Cons: You have to click

rigid laurel
#

it's not from the is-odd guy, it's a different person. Not sure if thats good or bad

tiny siren
#

help guys

#

https is saying that my website is not secure

#

but http is fine

cold anchor
#

if you don't have a certificate that supports https then the https connection will not be secure

tiny siren
#

@cold anchor can you help me fix it

cold anchor
#

that looks pretty explicit, you need to upgrade the version of tls that you support

tiny siren
#

how do i do that

cold anchor
#

depends on a lot of things, like the hosting service you're using primarily

tiny siren
#

google

cold anchor
#

can you be more explicit?

#

google cloud platform? google domains? google app engine..?

tiny siren
#

google cloud platform

cold anchor
#

just keep giving details please

tiny siren
#

ok

#

i use google cloud platform vm for my hosting

#

and i installed my certificate using certbot

#

ubuntu/apache

cold anchor
#

directly on a server? are you using a load balancer?

tiny siren
#

yes, over ssh. no load balancer.

cold anchor
#

ok, so you're pointing your domain name directly to your server that's running apache on port 443?

tiny siren
#

yes

#

i'll just double check though

cold anchor
#

when did you install the certificate?

tiny siren
#

about half an hour ago

cold anchor
tiny siren
#

yes

#

(18:04)

cold anchor
#

try following those instructions and see if it works

tiny siren
#

how do i edit the apache configuration? @cold anchor

cold anchor
#

do you know where the config is that you're running? this is pretty basic stuff, how did you get it running in the first place?

tiny siren
#

apt-get install apache2 xD?

#

i didn't have to configure anything

cold anchor
#

just google the default location for the apache config

tiny siren
#

apache2.conf ? @cold anchor

cold anchor
#

that sounds like the right file

tiny siren
#

then i'm doing something wrong

cold anchor
#

did you restart apache after editing that file?

tiny siren
#

i don't see it in the file

cold anchor
#

is that the whole file?

tiny siren
#

there's more but i don't see SSLProtocol -all +TLSv1.2

#

yeah it is not there

cold anchor
#

you'll have to add it whereever you're handling the domain routing

native tide
#

is it possible to make my website autoreload when i make changes to the code?

#

i'm using flask

outer apex
#

@native tide set the debug config variable to True

native tide
#

what does that do?

outer apex
#

Sorry, not quite the DEBUG!

native tide
#

i dont understand

#

export FLASK_ENV=development
$ flask run

#

i just run this?

outer apex
#

yup

cloud path
#

guys this query get me the error "str has no attribute id"

#

but i'm using owner that is declared int type and the id of the user that is also declared as int

#

solved

supple loom
#

Can anyone help me with dual booting linux with windows

tired root
#

#web-development : Help with web technologies such as Flask, Django, HTML, CSS, and JS.

supple loom
#

I know ...i asked in windows i got no response either

restive kindle
#

there are plently of tutorials on youtube

supple loom
#

I saw many...but something is different in my case... It's not showing the unallocated partition

feral minnow
#

It's a linux sub reddit I think they will help

foggy quarry
#

How to consume your own rest api, within your flask web app? do code like this considered good?

@app.route('/hello/<name>')
def hello(name):
    info = requests.get('http://localhost:5000/hello/'+name)
    return info.text
tame river
#

hello i am using django restframework and trying to make a simple API.
I declared my models and serializers but i get an error.

#

the error says ArtWork object has no attribute arts even tho i have declared arts = ArtSerializer(...) and also passed it in Meta of ArtWorkSerializer

tiny siren
hard moon
#

Hello, are there React Pros here?

cloud path
#

guys i should run a flask web app on a web app without SSH access, it is microsoft azure, so i cannot use the terminal to install gunicorn, and start it

#

is there a way to start the web app anyway?

wild thunder
#

hey, what is wrong in this chunk of code? ```html
<link rel="stylesheet" href="{ url_for('static', filename='signin.css')}" >

my css is not working at all
#

i have a bootstrap import above it and this,
the bs is via the link provided in the site, mine is from my machine, the folders are like

[static]
[css]
signin.css

feral minnow
#

You forget to put the css folder

#

<link rel="stylesheet" href="{ url_for('static', filename='css/signin.css')}" >

wild thunder
#

i guess i've tried that, but i'll do it again

#

if it's working, the problem is that it's not overwriting the bootstrap css

feral minnow
#

yup and if its not working I think you should restart the browser because this what I do so you press ctrl+shift+r

#

try to put it under the bootstrap link

wild thunder
#

it's already under :c

feral minnow
#

you saved the file?

#

wait

#

here's mine <link rel="stylesheet" href="{{ url_for('static', filename='css/signin.css') }}">

#

try this

#

maybe it will work i think you forget to put 2 {

wild thunder
#

wow

#

i guess

#

it worked

#

i'll try to overwrite some bs to see if it's really working

feral minnow
#

nice

wild thunder
#

how to use jinja to import just a chunk of code? like i dont want to extend

#

but idk what are the keywords

#

to search online

#

i want to make a file fonts.html

#

throw all my font links in there

#

and push it to the main 'base.html' file

cloud path
#

hey guys

#

does anyone know a good guide to run up a flask web app on microsoft azure?

midnight geyser
feral minnow
#

nice website

#

Guys im making a project which scrape data from another website but at some point it freeze

#

and stop scraping/downloading

#

so is the problem from my pc or I have a mistake in the program but it work fine without error it just freeze and stop scraping?

#

or is it a problem from the website im taking data from becuase im sending too many requests?

rigid laurel
#

It's probably a code issue

feral minnow
#

oh

#

are you sure because it download it normally but suddenly stop

#

the downloading process is too slow lol

rigid laurel
#

It's possible you're getting stuck in some tricky infinite loop that you can't see. Or that you're scraping has somehow got you endlessly bouncing between two links. It seems unlikely to me that the code is just freezing - and if it is, its probably not freezing, just you're not accounting for some behaviour that you need to be. It's very difficult to provide help with actual code.

IF you're looking to debug, try removing as many factors as possible, then adding them back bit by bit til you encounter the problem again

feral minnow
#
        #Get the html code & create beautifulSoup object
        link = link
        res = requests.get(link)
        res.raise_for_status()
        soup = bs(res.text,"html.parser")
       
           #Get the folder name
        regexName = re.compile(r'chapter-\w+\.?\w*/?')
        regexFind = regexName.search(link).group()
        print(f"This is it {regexFind}")
        fullName = regexFind
        #print(fullName)
        
        if not os.path.exists(f'/tmp/server/manga/{folderName}/{fullName}'):
            os.makedirs(f'/tmp/server/manga/{folderName}/{fullName}')  #create the chapter file  

        imgElem = soup.select("body > div.body-site > div.container-chapter-reader > img")#Get the css selector for the manga image
        print(len(imgElem))       
        for i in range(len(imgElem)):#Page loop
            src = imgElem[i].get('src')
            fullLink = src
            print(src)
            res = requests.get(fullLink)
                    
           
            
            animeFile=open(os.path.join(f'/tmp/server/manga/{folderName}/{fullName}',os.path.basename(fullLink)),'wb+')#file name
                   
            print(f'\nDownloading  {fullLink}')
            for chunk in res.iter_content(100000):#File download
                animeFile.write(chunk)
            animeFile.close()
        print(f'\n{fullName} Is Done\n')
        nextElem=soup.select('a.navi-change-chapter-btn-next')#Get the css selector for the next button
        try:
            href=nextElem[0].get('href')#Link for the next chapter
        except IndexError:
               flash("Thanks for using our website")
              
                
        folderPath = f"/tmp/server/manga/{folderName}"   
           link=href
        if fullName == chEnd:
            flash("Downloaded files to the server successfully.")
            zip_files(folderPath)
            break
        #link=href```
#

@rigid laurel thx... here's the code

#

I have a while loop but i don't think its the problem

#

because the problem happen inside the first for loop

sudden crest
#

why the hell does Jinja not put the super() block where you goddamn tell it to

#

it always puts the inherited stuff after

#

i mean come on

#

that's completely stupid

#

what possible advantage does that have

#

/rant

native tide
#

I am looking to integrate a rest API with a discord bot, but I am not 100% sure the best way to do it. Threading the Flask/Quart/AIOHTTP receiver really doesn't solve the issue of being able to communiate with the main thread where my bot it. Any ideas to point me in the right direction for reasearch?

forest summit
#

is there anyone here who can help me with python

zealous siren
#

Kocis shove it in container

#

Then run it in web app

quasi ridge
#

wrong channel?

quasi ridge
#

oh 🙂

elder nebula
#

I am doing appointment application with python and I have all done except calendar. Is there ready to go django calendar package what let's you locate appointment with date & time

#

I have checked out FullCalendar, but it only let's you use the schedule if you share the source code.

cloud path
#

guys how can i deploy my flask web app with build automation turned on 'ON'?

#

to make the system doing "install -r requirements.txt" automatically

#

@zealous siren thanks i noticed right now your reply sorry

#

btw what about the requirements?

#

azure doesn't have a SSH to do the command to activate the env or install the requirements

#

it has just a row to do the startup command

native tide
#

is flask-login feature client validation or server validation

#

?

restive kindle
#

Everything to do with validation is server side

native tide
#

doesn't js do client side form validaiton?

restive kindle
#

You mean checking if a field is empty or like logging in.

solar hatch
#

Any rest api/API Projects

#

Easy

#

And I don't know the difference between rest and api

languid kite
native tide
#

@native tide validation is always server-side

solar hatch
#

Any projects

#

@native tide

#

With flask

native tide
#

With flask
@solar hatch Flask-rest framework or just Flask without the framework?

solar hatch
#

Without

#

@native tide

native tide
#

Create a weather app with Flask

frosty mauve
#

In my Django Template, I am using {{song.books.all|join:"," }}, this is returning a list of books from each song. Each book has an endpoint but when I use <a href it hyperlinks the entire joined list of books. I would like to hyper link each book with it's own href. Anyway I can pass join with href?

frosty mauve
#

Anyone?

zealous siren
#

@cloud path You need to build a container, put it in Container Registry then let Azure Web App pull the container down and run it

#

Azure has container registry and you can even build using Container Registry or build in Azure Devops or build inside your own build system and push to Azure Registry Container

candid gull
#

I posted this in general; did not realise their was a specific channel.

#

Hi all, I'm new to Python. I am using Flask to create a small REST API. This REST API has a middleware where I want to add a header to the request to access it in the Resource (I am using Flask-RESTful). I get an error that the .headers is immutable... is there a way to create a new header, i.e. X-User-Id? Or, how would you pass something from a middleware to the Resource?

#

The middleware:

def user_id_header(f):
    def get_and_load_jwk():
        r = requests.get('http://oathkeeper-api:4456/.well-known/jwks.json')
        key = r.json()['keys'][0]
        jwk = JsonWebKey(algorithms=JWK_ALGORITHMS)
        return jwk.loads(key)

    @wraps(f)
    def inject_user_id(*args, **kwargs):
        token = request.headers.get('Authorization').split(' ')[1]
        jwk = get_and_load_jwk()
        sub = jwt.decode(token, jwk)['sub']
        print(sub, file=sys.stderr)
        request.headers.set('x-user-id', sub)
        return f(*args, **kwargs)
    return inject_user_id
cold anchor
#

in general you shouldn't be modifying the incoming request headers

#

the client sent you a request and you should honor (or not honor) what comes in, but you shouldn't modify it

#

if you want to use a "context local" over the period of processing a request, this is exactly what flask.g is for. in your case flask.g.current_user_id = sub and you can access flask.g.current_user_id anywhere in your code that is in the context of a request

candid gull
#

Brilliant! I did not know Flask offered per request context.

#

Thanks @cold anchor

#

@cold anchor Is g an extra package I need to import?

cold anchor
#

nope

#

from flask import g

candid gull
#

Yeah, figured

#

Thanks!

spiral oak
#

Hello, I've been installed django. I have a probleme because when I use a command (ex: django-admin startproject) files are created but nothing is written in the CMD. Actually this becomes a problem when I try to do python .\manage.py makemigration or python .\manage.py createsuperuser ...
I had reinstall 4 times python switching between 3.7 and 3.8 and I don't understand the probleme.
If somebody have an idea I'm listening

nota bene : pip install ... has traceback

queen bough
#

@spiral oak Can you try PowerShell?

#

It's probably an issue with your CMD not Python/Django, though.

spiral oak
#

it seems not, the power shell has the same issue

queen bough
#

@spiral oak Can you post a screenshot?

spiral oak
#

the server run in pycharm

obsidian parrot
#

is it better to use django or flask

#

im gonna be using a couple api's

#

and mySQL

zealous siren
#

Are you building API or consuming them?

obsidian parrot
#

consuming

#

its my first time so

#

consuming them

zealous siren
#

then doing what with data?

#

do either, consuming APIs doesn't matter, you can do that with aiohttp or requests

#

don't even need Django/Flask for that

obsidian parrot
#

basically what im doing

#

i made a layout for myself, its the first time im taking on a challenge like this

#

i had an idea to make like a website you could go on, you would log in and you could get notifications from all of your applications

#

so like instead of going to every indivisual thing like gmail, and then insta, and then opening up snapchat

#

just as an example

#

if you click on any of the notifications it will direct you to the website

zealous siren
#

ok, so Flask is quicker to get going, Django more powerful

#

pick whatever poison you want to start with

obsidian parrot
#

ahh i see

native tide
#

anyone in here familiar with WP steam auth and tournamatch ? (for the wordpress)

native tide
#

im learning in that class right now @shy holly

shy holly
#

@native tide nice

native tide
#

idk

shy holly
#

Django
Do you guys know how to change a specific template,
I want to change the "change_list.html" template but only for a certain app

shy holly
#

how I solved it :

{% if opts.app_label == 'MY APP NAME' %}
HTML CODE
{% endif %}```
tired lava
#

guys

#

If I bought a domain

#

can I just use it on wordpress

#

or will it cost me a fee?

native tide
grave hound
#

@obsidian parrot from my experience, if you are going to be making user accounts, I would suggest using Django

#

makes it much easier to also know Flask before learning Django

gilded monolith
#

i'm starting next week at a new job, they use PostGresSQL and django, what are their strong point compared to flask and MySQL. What little project could i do, specifically to understand the strength of both of them, in a short time (5/10h? )

#

what problem do they resolve in other words

grave hound
#

@gilded monolith I haven't used PostGresSQL or MySQL but I can give some basic advice on Flask and Django. Flask is a really good "microframework" that allows you to build simple websites fast. So you can build a website that does simple jobs, probably something like a page about yourself or something like that, nothing with user accounts and things like that. Django is a much more advanced web framework that simplifies making web apps a lot but also allows you to have a lot of control over it. I haven't used it much but it made having users on my page a lot simpler, because Django handles everything (hashing SHA-256 and salting) of passwords and it has an admin page to use to look over your page's details

#

I don't know if I am spreading misinformation but that is what I got from building a small website

#

It also uses sqlite3 for database management in a very simple way

#

But you can change that after starting your project

gilded monolith
#

Yeah i already did smol stuff with Flask and such, i was just wondering what i should pay attention to and what knowledge to quick grab

drowsy river
#

hello everyone, currently building a Django webapp as a front end to my Postgresql database. I am using elastic beanstalk to deploy to AWS (the database also lives on AWS). The website works locally (it's just a simple table at the moment) but whenever i run eb deploy i get the following error:
2020-04-28 10:23:56 ERROR [Instance: i-0e140fa936b76bee1] Command failed on instance. An unexpected error has occurred [ErrorCode: 0000000001].
2020-04-28 10:23:56 INFO Command execution completed on all instances. Summary: [Successful: 0, Failed: 1].

#

I can't really seem to find advice online for this error, and have followed tutorials to get to this point (including the AWS guide). But I can't seem to figure it out. Is there some rookie mistake I am making here, looking for any help have been stuck for 3-4 hours on this.

tender crater
#

I am currently working in Flask, I am looking for a way to serialize a SQLAlchemy model to JSON (to build an /api route). Anybody has any advice on best practices?

cold anchor
frosty mauve
#

Uhhhhh, I must be silly but in Django I am trying to give a rating to a book. I made a view that will create a rating for a book by passing in the current book, and a integer rating. This does work if I use rating/stars=5 but I want to populate this with the value from a select element. Does anyone know how to do this?

`<select id="rater">
<option value="1">1</option>
....
</select>

<a href="{% url 'books:submit-rating' bookpk=book.pk stars=5 %}" class='btn btn-success' type="submit">Rate Item!</a>
<a href="{% url 'books:submit-rating' bookpk=book.pk stars=rater.value %}" class='btn btn-success' type="submit">Rate Item!</a> `

gilded monolith
#

your html request doesn't contain the selected value ? i had similar problem with flask because it was <select name="rater"> for some reason

#

not sure if i understand your problem and if that's gonna resolve it anyway :/

frosty mauve
#

@gilded monolith I added form action before it - and it is processing now. However since there are several cards with the same form, it is only updating the first one....

tiny siren
#

is it bad to redirect an unsecure dns to a secure one?

glass sandal
#

Guys I made a flask chat website with flask-websocket and flask but when I deployed it to heroku it is unable to connect to it

#

Like the website loads

#

But the socket doesn't

#

And I can't send messages

#

The code looks like this :

from flask import Flask, render_template, request, make_response
from flask_socketio import SocketIO, send

app = Flask(__name__)
app.config["SECRET_KEY"] = "dsa987hda*&^SD*(Q*^Tia7sd"
socketio = SocketIO(app,cors_allowed_origins="*")

@app.route('/')
def index():
    return render_template("index.html")

@socketio.on('message')
def handle_msg(msg):
    send(msg, broadcast=True)
#

The HTML :

<html>
    <head>
        <title>Hello</title>
        <script type="text/javascript" src="static/socket.io.js"></script>
        <script src="static/jquery.min.js"></script>
    </head>
    <body>
        <script type="text/javascript">
            $(document).ready(function () {
                var socket = io.connect("https://chath2o.herokuapp.com/");

                socket.on("connect", function () {
                    socket.send("User has connected!");
                });

                socket.on("message", function (msg) {
                    $("#messages").append("<li>" + msg + "</li>");
                });

                $("#sendButton").on("click",function() {
                    socket.send("User : " + $('#myMessage').val());
                    $('#myMessage').val('');
                });
            });
        </script>
        <ul id="messages"></ul>
        <input type="text" id="myMessage" />
        <button id="sendButton">Send</button>
    </body>
</html>
#

WSGI.py :

from app import socketio, app

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

does Heroku handle Websockets?

cold anchor
#

yes

zealous siren
#

Radarh2o, free Heroku?

cold anchor
#

I have a running socket server on Heroku (https://app.metrecord.com) and it's on a paid server, but even when it was free, I just had to set the socket disconnect/reconnect to be every 45 seconds instead of holding the connection because heroku stops it at 55 seconds

#

looks like a lot of 400s, might be good to check the logs

glass sandal
#

Yes free server

#

And always it keeps giving "POST 400"

#

Something like that

zealous siren
#

Heroku is just so limiting, it's sometimes hard to tell what's app and what's not

glass sandal
#

I mean is it a fix?

#

Like any alternative

#

or any more lines of code

zealous siren
#

put it into container, run it somewhere else?

#

that will cost money

glass sandal
#

I mean like any alternative websites (Except pythonanywhere)

zealous siren
#

digitalocean

#

linode

glass sandal
#

And it is paid?

zealous siren
#

yes

glass sandal
#

Isn't there free ones?

zealous siren
#

compute costs money

cold anchor
#

deploying to a different place won't get rid of the 400s unless they're caused by the infrastructure

#

which is unlikely

zealous siren
#

well, I assume it works locally

glass sandal
#

It works

#

I tested on our local wifi

cold anchor
#

find the root of the 400s

glass sandal
#

And like no 400s

zealous siren
#

what 400 are you getting?

cold anchor
#

have you looked at the logs?

glass sandal
#

Yea

cold anchor
#

what do they say?

glass sandal
#

Wait I send it

#
2020-04-28T15:41:06.640684+00:00 app[web.1]: 10.11.150.203 - - [28/Apr/2020:15:41:06 +0000] "GET /socket.io/?EIO=3&transport=polling&t=N71SkoE&sid=e9ee2db286e940d2ab54ed454729aff5 HTTP/1.1" 200 39 "https://chath2o.herokuapp.com/" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:76.0) Gecko/20100101 Firefox/76.0"
2020-04-28T15:41:06.542476+00:00 heroku[router]: at=info method=GET path="/socket.io/?EIO=3&transport=polling&t=N71SknE" host=chath2o.herokuapp.com request_id=d67544f8-cafd-40e4-9b8f-df4777b4968f fwd="65.96.225.92" dyno=web.1 connect=0ms service=3ms status=200 bytes=375 protocol=https
2020-04-28T15:41:06.643429+00:00 heroku[router]: at=info method=GET path="/socket.io/?EIO=3&transport=polling&t=N71SkoE&sid=e9ee2db286e940d2ab54ed454729aff5" host=chath2o.herokuapp.com request_id=5fec1b35-e7be-41ff-8824-84c5a88475c5 fwd="65.96.225.92" dyno=web.1 connect=1ms service=7ms status=200 bytes=258 protocol=https
2020-04-28T15:41:06.638383+00:00 heroku[router]: at=info method=POST path="/socket.io/?EIO=3&transport=polling&t=N71SkoC&sid=e9ee2db286e940d2ab54ed454729aff5" host=chath2o.herokuapp.com request_id=c2f4a5c3-1f1d-49c2-9017-47a34dbc0a94 fwd="65.96.225.92" dyno=web.1 connect=2ms service=4ms status=200 bytes=266 protocol=https
2020-04-28T15:41:18.606198+00:00 heroku[router]: at=error code=H12 desc="Request timeout" method=GET path="/socket.io/?EIO=3&transport=polling&t=N71SYoM&sid=37cd16e0033e4e77af9f6e6f2e66b738" host=chath2o.herokuapp.com request_id=49924344-ed06-4448-8f70-c4cacefbd6f1 fwd="108.18.36.173" dyno=web.1 connect=0ms service=30001ms status=503 bytes=0 protocol=https```
#

And

#

The error :

#
Failed to load resource: the server responded with a status of 400 (BAD REQUEST)
#

In the console

#

of the browser

#

And it keeps trying to connect and spams "User has connected" (It reconnects every 10 secs

#

)

zealous siren
#

my guess is Heroku Load balancer is getting mad

#

lower time as baker suggested

glass sandal
#

Should I try connecting Javascript's socket to domain IP?

cold anchor
#

especially the Procfile

glass sandal
#

hmmmmm

#

I'll try the Procfile

#

And btw

#

The site ip has the same port as a normal flask app? (5000) or 80?

cold anchor
#

heroku will always give your site ports 80 and 443

glass sandal
#

Oh

#

I mean what could be the problem? Heroku or the code?

#

Cause the code works perfect locally

tiny siren
#

what happens if you get 2 in binary 😳

glass sandal
#

But when I deploy it doesn't connect to flask-websocket

tiny siren
#

that's what happens when you use free

glass sandal
#

Maybe

cold anchor
#

it's pretty sweeping to say this is caused by using the free tier vs the complexities of deploying to a remote server

#

what's your procfile?

tiny siren
#

how come my main domain is protected and my subdomain isn't

#

i am using a loadbalancer :)

cold anchor
#

what do you mean by protected?

#

(is this AWS?)

tiny siren
#

GCP

#

i mean secure

#

ssl

zealous siren
tiny siren
#

the certificate should protect all subdomains

zealous siren
#

no

tiny siren
#

?

zealous siren
#

the certificate may or may not protect all subdomains, and again DNS can bite you

#

welcome to my world

rich plaza
lavish prismBOT
#

Hey @glass sandal!

It looks like you tried to attach file type(s) that we do not allow (.txt). We currently allow the following file types: .3gp, .3g2, .avi, .bmp, .gif, .h264, .jpg, .jpeg, .m4v, .mkv, .mov, .mp4, .mpeg, .mpg, .png, .tiff, .wmv, .svg, .psd, .ai, .aep, .xcf, .mp3, .wav, .ogg.

Feel free to ask in #community-meta if you think this is a mistake.

glass sandal
#

Tried installing geventwebsocket and got :

remote:        ERROR: Command errored out with exit status 1: /app/.heroku/python/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-l39jxgzd/geventwebsocket/setup.py'"'"'; __file__='"'"'/tmp/pip-install-l39jxgzd/geventwebsocket/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-zi7pewjq/install-record.txt --single-version-externally-managed --compile --install-headers /app/.heroku/python/include/python3.6m/geventwebsocket Check the logs for full command output.
remote:  !     Push rejected, failed to compile Python app.
remote:
remote:  !     Push failed
remote: Verifying deploy...
remote:
remote: !       Push rejected to chath2o.
remote:
To https://git.heroku.com/chath2o.git
 ! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/chath2o.git'
#

And before that :

remote:             command: /app/.heroku/python/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-l39jxgzd/geventwebsocket/setup.py'"'"'; __file__='"'"'/tmp/pip-install-l39jxgzd/geventwebsocket/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-zi7pewjq/install-record.txt --single-version-externally-managed --compile --install-headers /app/.heroku/python/include/python3.6m/geventwebsocket
remote:                 cwd: /tmp/pip-install-l39jxgzd/geventwebsocket/
remote:            Complete output (14 lines):
remote:            running install
remote:            Traceback (most recent call last):
remote:              File "<string>", line 1, in <module>
remote:              File "/tmp/pip-install-l39jxgzd/geventwebsocket/setup.py", line 47, in <module>
remote:                'geventwebsocket = geventwebsocket.cli:cli',
remote:              File "/app/.heroku/python/lib/python3.6/distutils/core.py", line 148, in setup
remote:                dist.run_commands()
remote:              File "/app/.heroku/python/lib/python3.6/distutils/dist.py", line 955, in run_commands
remote:                self.run_command(cmd)
remote:              File "/app/.heroku/python/lib/python3.6/distutils/dist.py", line 974, in run_command
remote:                cmd_obj.run()
remote:              File "/tmp/pip-install-l39jxgzd/geventwebsocket/setup.py", line 20, in run
remote:                raise Exception("You probably meant to install and run gevent-websocket")
remote:            Exception: You probably meant to install and run gevent-websocket
onyx crane
#

Django
What is the normal way of populating fields in your model that are not reliant on user input, but on some calculations or references.

I "solved" it buy building an __init__ function, but for some reason that messes with the Inherited Models class ...
Is there a default other way, or is there something that im missing ? (Couldnt get the super().__init__ to work either)

 def __init__(self):
        self.pc_slug = self.pc_name.replace(" ", "-")

        self.pc_hpMax = self.calc_modifier(self.pc_con) * 20 + self.pc_race.race_hp
        self.pc_init = self.calc_modifier(self.pc_rfx) + 6
        self.pc_speed = self.pc_race.race_speed
        self.pc_carryMax = self.calc_modifier(self.pc_str) * 5 + self.pc_race.race_carry
supple loom
#
  File "./main.py", line 7, in <module>
    from app import crud, models, schemas
  File "./app/crud.py", line 3, in <module>
    from . import models, schemas
  File "./app/schemas/__init__.py", line 1, in <module>
    from .item import Item, ItemCreate, ItemInDB, ItemUpdate
ModuleNotFoundError: No module named 'app.schemas.item'
#

i am getting this error while i have no such schemas in my schemas.py file

#

named as Item or ItemCreate and the rest

#

this is an fastApi issue

glass sandal
#

Guys can someone explain me why do we use api ?

#

I mean like ok I've sent JSON data to server and got a JSON response . So why is this thing so used?

#

And can you give me real life examples

outer apex
onyx crane
#

Oh damn ! thx!

outer apex
#

Unfortunately I am not sure about the internals. For that you might have to look at how Django handles all of this and what it uses __init__ for. Or wait for someone who knows better to respond! 😛

onyx crane
#

this works great if youre not planning to use the admin panel :D

outer apex
#

@supple loom do you have something called item defined somewhere - a file, function?

#

@glass sandal Social media API is one good example. Let's say I asked you in how many of Guido's tweets does he mention the word Python.

  1. You could literally scour his Twitter page and count
  2. You could build a scraper that looks at the page and count
  3. You can hit the Twitter API, collect all tweets, and count
#

API solves this one way of interfacing with data - where you want to this data over a period of time.

#

API can also help centralise data from distributed sources. Let's say COVID-19 data in the US. If you were interested in data from different states and there isn't one built on the Federal level, you could have an API interface that allows you to query state-level data, while in the backend of that API queries individual states.

zealous siren
#

Rader, containerize it and find out

supple loom
#

@outer apex no i don't ...i had (but i changed) in my schemas file before but not all of the above mentioned....so i don't think it's related.
paste.pythondiscord.com/kawezinoye.py
this is my schemas file

#

File "./app/schemas/init.py", line 1, in <module>

check this line ..i have no init file either

outer apex
#

what's your directory structure?

supple loom
#

C:\Users\prashant\Desktop\india_scanner\app\IS\backend\app

#

this is where the main file lies

#

C:\Users\prashant\Desktop\india_scanner\app\IS\backend\app\app
and this is where schemas and other files lies

outer apex
glass sandal
pseudo nacelle
#

this is not necessarily python. But I was wondering if there is a way to see if a user copied (Ctrl C) a line from a website

#

I don't want to force them to copy to clipboard

#

but at least see what % of users are copying said code

#

is this possible at all?

cold anchor
#

You might want to use that to detect it and then when it happens, save that a user copied some text

pseudo nacelle
#

the question is the same as mine. but the answer is how to disable that functionality

#

I wonder if it is just not possible

cold anchor
pseudo nacelle
#

ahh. thanks @cold anchor

native tide
#

In what folder would you guys put a django install in server side? Some people said to make a new directory called /srv

native tide
#

I wrote a extremely simple rest framework that only supports json format! You can check it and give me ur thoughts https://gitlab.com/PanTrakX/rstx

native tide
#

Hello, I was wondering if theres a way to have a variable for a <img> tag, instead of an absolute url, without using js

empty pivot
#

@native tide can you explain further what you want to do?

native tide
#

I'm creating a leaderboard on my webpage that auto updates user rankings, & I need the <img> section of a table to update to whoevers in 1st place in the DB..

#

Hence why I need a way to change the <img src=> link

empty pivot
#

Oh okay you want to programmatically change the URL value of src in an <img/> tag

native tide
#

Mhm

empty pivot
#

Are you using Django or flask to serve this HTML?

native tide
#

Django

empty pivot
#

So in your template can you set the value of the src attribute to be variable you pass into the template when you render it?

native tide
#

I was trying to use jinja syntax to input a link from a SQLite DB in the img field

#

<img src={{user.Discord_Avatar_URL}}> which obviously won't work because it just wants a string URL

empty pivot
gaunt knot
#

I need help

#

Somebody please help me

empty pivot
#

Just tell what's up

solar hatch
#

Node js projects

#

???

#

Beginner

teal sleet
#

Hi I am a newbie in python and web development I encountered a problem and its been couple of hours now 😕 . Hope someone can help or lead me to the answer 🙂 thanks in advance! Here's the error I get. screenshot

Virtualenv name: blog
forms.py
flaskblog.py

flask.cli.NoAppException: While importing "flaskblog", an ImportError was raised:

Traceback (most recent call last):
File "c:\users\avalgp\documents\flask_blog\blog\lib\site-packages\flask\cli.py", line 240, in locate_app
import(module_name)
File "C:\Users\avalgp\Documents\flask_blog\flaskblog.py", line 2, in <module>
from forms import RegistrationForm, LoginForm
File "C:\Users\avalgp\Documents\flask_blog\forms.py", line 3, in <module>
from wtforms.validators import DataRequired, Lenght, Email, EqualTo
ImportError: cannot import name 'Lenght' from 'wtforms.validators' (c:\users\avalgp\documents\flask_blog\blog\lib\site-packages\wtforms\validators.py)

#

I tried to reinstall flask-wtf and see if that helps but this is what I get. I tried to google it but when I started reading through their answers I get lost more. 🥴

teal sleet
#

All good I somehow managed to make it work 😄

shy holly
onyx crane
#

im not sure what youre asking

#

what is the "info"

#

and where do you want to get it to ?

shy holly
#

like I want to get the selected users id , name , email ..etc

#

and where do you want to get it to ?
@onyx crane I'm trying to make a function that uses these "info" in something when a button is clicked

#

perhaps an action

onyx crane
#

Youre trying to access the stuff from code => youre not accessing it through the admin panel ...

#

If you click on the Blue Links in the Admin Panel you can see all the columns ... if thats what you mean.

shy holly
#

Youre trying to access the stuff from code => youre not accessing it through the admin panel ...
@onyx crane right

#

I've a button when this button is clicked I want to get the selected users

onyx crane
#

Where do you have this button ?

#

Can you explain me what youre trying to do ?
I think youre missing something major here

shy holly
#

in this template "change_list.html"

onyx crane
#

Ok. The Admin panel, and the selections you do in it, have nothing to do with what youre trying to do.

#

You want to display all instances of a specific Model in a template ?

shy holly
#

nope I want to get the instances of a specific model bec I need the user id to use it in Google API

onyx crane
#

You just said no and then repeated what i asked ...

shy holly
#

duckyhunt sorry

onyx crane
#

Views.py

from .models import Yourmodel

def testview(request):
    return render(request = request,
                template_name='appname/yourtemplate.html',
                context = {"yourmodel": Yourmodel.objects.all})
shy holly
#

and how do I filter by the selected ones ?

onyx crane
#

Urls.py:

urlpatterns = [
    path("", views.testview, name="testview"),
#

one after another

supple loom
#

@outer apex i was getting that error coz i had a folder in the same directory with the same name as schemas

onyx crane
#

yourtemplate.html

<body>
{% block content %}
  {% for modelinstance in yourmodel%} 
    <p>{{modelinstance.columnname}} </p>
  {% endfor %}
{% endblock %}
</body>
#

see if you get that too work

#

and display your model instances (users?)

finite lava
#

Anyone know how i can use Flask/Django to extract the HAR file of people visiting my website?

shy holly
#

@onyx crane

class ClassesAdminENG(DjangoObjectActions,admin.ModelAdmin):
    def testview(request):
        all_personalInfo = StudentsEng.objects.all()
        return render(request=request,
                      template_name='admin:students_studentseng_changelist',
                      context={"infos": all_personalInfo})```
inside changelist.html:

{% for modelinstance in infos %}
<p>{{modelinstance.name}} </p>
{% endfor %}```

#

unfortunately it didn't display anything

#

that worked :

        response = super(ClassesAdminENG, self).changelist_view(request, extra_context)
        all_personalInfo = StudentsEng.objects.all()
        extra_context = {
             "infos": all_personalInfo,
        }
        response.context_data.update(extra_context)

        return response ```
#

now let's go back to the main question

harsh flare
#

Whats the best way in Flask to call a template and pull in a python variable from a list in the app to populate the webpage? For example, I have a list of lists with each list containing details I'd like to populate a webpage with. How do I efficiently call and populate the template for each list? Bonus points for how I do this as a hyperlink on a homepage

versed sigil
#

have a route.
route has data from (form?, db?, config file? variable?)
route does its job and calls the template passing in the req'd variable

#

route needs to accept GET and POST
GET then nothing has been submitted so just display the default behavior
POST then a link has been clicked that has ? in the URL so you can now have your route process the POST action

feral minnow
#

.lds-roller {
  display: inline-block;
  position: relative;
  width: 80px;
  height: 80px;
}
.lds-roller div {
  animation: lds-roller 1.2s cubic-bezier(0.5, 0, 0.5, 1) infinite;
  transform-origin: 40px 40px;
}
.lds-roller div:after {
  content: "";

  display: block;
  text-align: center;
  position: absolute;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: black;
  margin: -4px 0 0 -4px;
}
.lds-roller div:nth-child(1) {
  animation-delay: -0.036s;
}
.lds-roller div:nth-child(1):after {
  top: 63px;
  left: 63px;
}
.lds-roller div:nth-child(2) {
  animation-delay: -0.072s;
}
.lds-roller div:nth-child(2):after {
  top: 68px;
  left: 56px;
}
.lds-roller div:nth-child(3) {
  animation-delay: -0.108s;
}
.lds-roller div:nth-child(3):after {
  top: 71px;
  left: 48px;
}
.lds-roller div:nth-child(4) {
  animation-delay: -0.144s;
}
.lds-roller div:nth-child(4):after {
  top: 72px;
  left: 40px;
}
.lds-roller div:nth-child(5) {
  animation-delay: -0.18s;
}
.lds-roller div:nth-child(5):after {
  top: 71px;
  left: 32px;
}
.lds-roller div:nth-child(6) {
  animation-delay: -0.216s;
}
.lds-roller div:nth-child(6):after {
  top: 68px;
  left: 24px;
}
.lds-roller div:nth-child(7) {
  animation-delay: -0.252s;
}
.lds-roller div:nth-child(7):after {
  top: 63px;
  left: 17px;
}
.lds-roller div:nth-child(8) {
  animation-delay: -0.288s;
}
.lds-roller div:nth-child(8):after {
  top: 56px;
  left: 12px;
}
@keyframes lds-roller {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}
``` whats up guys, This is a 3 dot css animation I did'nt create it I just get it from another site ..., how I can put it in the middle of the page?
#

I tried text align but its not working

shy holly
#
  position: fixed;
  top: 50%;
  left: 50%;
  /* bring your own prefixes */
  transform: translate(-50%, -50%);
}```
feral minnow
#

Thanks but what prefixes are I don't know much about css?

harsh flare
#

@versed sigil thanks, this helps! Is there good tutorial to follow to make sure I do this correctly?

idle bloom
#

I feel so stupid and cannot find a answer for this, I am making a postage tracker, I am making a get request to this url https://www.fastway.com.au/tracking-api/?callback&LabelNo=<LABLEGOESHERE>&dataFormat=json
I can parse the tracking numbers perfect but not to were I want it to go.

#

if I can just get an explanation do not have to be told exactly I have tried, a few diff ways and cannot seem to get it to work.

wild thunder
#

hey guys, i'm using flask-login and i'm struggling a little, i am getting this message when i try to login.

my dashboard has an @login_required below the route

#
@app.route('/login', methods=['GET', 'POST'])
def login():
    if request.method == 'POST':
        username = request.form['username']
        password = request.form['password']

        user = User.query.filter_by(username=username).first()

        if not user or not user.check_password(password):
            flash("not successful.")
            return redirect('/login')
        else:
            user.is_authenticated = True
            login_user(user, remember=True)
            return redirect('/dashboard')

    else:
        return render_template('login.html')
#

this is the login code

#

i tried some alterations but had no success

ancient basalt
#

anyone here familiar with Django? I am trying to make model form but not sure if i need to incorporate a formset using two different classes of models

distant ferry
#

is there anyone interested in joining a personal private github project? We are 3 developers, 2 moviemakers and one CEO. We're building a live streaming progressive web app and we're aiming to become a startup in the future.
any developers interested and looking for experience would be really appreciated. It's Laravel, Vue and Livepperjs

inland fossil
#

so ive got an issue here,

@app.route('/api/servers', methods=["GET", "POST"])
def setstatus():
    if request.method == "GET":
        print(serverList)
        return jsonify({
            "servers": serverList
        })
    elif request.method == "POST":
        servername = request.headers['servername']
        serverip = request.headers['ip']
        servermap = request.headers['map']
        serverport = request.headers['port']
        serverid = id_generator()

        server = {
            "ip": serverip,
            "port": serverport,
            "name": servername,
            "map": servermap,
            "id": serverid
        }

        serverList.append(server)

        print(serverList)

        return jsonify({
            "res": "OK",
            "server": server
        })

I can only see the changed serverList array in the elif and nowhere else. serverList is like so: serverList = [] at the top of the file. In the GET request, it only returns { "servers": [] } and I don't know what to do. Thanks!

wooden flume
#

@inland fossil you need to save it somewhere if you wanna access it later

inland fossil
#

i have

#

but i found the issue, for some weird reason, it cant read the serverList that I have defined earlier up at the top.

wooden flume
#

well, i can't see where you defined it

inland fossil
#
from flask import Flask, render_template, jsonify, request
import socket
import time
import atexit
import random
import string
import requests

from apscheduler.schedulers.background import BackgroundScheduler



app = Flask(__name__)

def isOpen(ip, port):
   s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
   try:
      before = int(round(time.time() * 1000))
      s.connect((ip, int(port)))
      after = int(round(time.time() * 1000))
      s.shutdown(2)
      return True
   except:
      return False

serverList = []

def getPing(ip, port):
   s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
   try:
      before = int(round(time.time() * 1000))
      s.connect((ip, int(port)))
      after = int(round(time.time() * 1000))
      s.shutdown(2)
      return after-before
   except AssertionError as error:
      return error

...

def check_all_servers():
    statusCheck()
    for server in serverList:
        if isOpen(server["ip"], server['port']):
            return True
        else:
            serverList.remove(server)
            return False

def id_generator(size=12, chars=string.ascii_uppercase + string.digits):
        return ''.join(random.choice(chars) for _ in range(size))

check_all_servers()
scheduler = BackgroundScheduler()
scheduler.add_job(func=check_all_servers, trigger="interval", seconds=3)
scheduler.start()

# Shut down the scheduler when exiting the app
atexit.register(lambda: scheduler.shutdown())
#

right in the middle

short escarp
#

As I undestand it, HTML, CSS and Javascript are often used together. I think I need HTML to view code in CSS or Javascript, but should I learn either Javascript or CSS first and then the other, or is it reasonable to try and learn both at the same time? I already know some Java, so I'm guessing Javascript is the better one to start with if I'm doing one at the time.

versed sigil
#

@short escarp youre going to need to understand HTML DOM and CSS sectors are a minimum to get started with javascript.

#

well I mean you can get started with javascript w/o knowing those to learn the syntax, but the real power of JS is when you start manipulating the DOM

onyx crane
#

@short escarp lets say html lets you add your text, videos, links, images. Css lets you style that stuff. (color in text, add margins left right and center and position your stuff.) Javascript then on top lets you put logic for your website or any kind of functionality. You press a button and something is supposed to happen. Javascript. You want to transform something. Javascript. And basically everything else.

#

Django:

  1. When i use the .save method of my ModelForm, i think the .save method of my reference Model gets called.
    I already overwrote the save Method of my Model which worked perfectly. Now i want to make the ModelForm call a "first_create" method that is an extended version of my overwritten .save method of my Model. This does not work though.
round ferry
#

Hi, how can I create checkbox which works dynamic in Django. Like when I click that check box it should strike some text.

thorny rover
#

are there any good tools that will help me make a front end of the website (HTML, CSS, JavaScript) and then let me tie in my python code for the back end and database) I saw Bootstrap Studio and it seems nice, im willing to buy something

versed sigil
#

there are many many good free templates available. You find one you fancy, download it and then change it to suit your needs. Flask is easy enough to use with its Jinja templating engine to connect python to your front end

#

@round ferry you need to use client side javascript for that

thorny rover
#

im looking for a program really that is drag and drop that then gives the source HTML code

versed sigil
#

then youre out of luck as far as i know.

#

get the free template
edit to work with flask

#

what it sounds like youre really needing is a simple site that something like squarespace provides

#

you should look at that @thorny rover

thorny rover
#

does square space integrate well with stuff like flask?

fossil thicket
#

I have a HTML report which autogenerates every time I change the analysis, which I have open in a browser window.

However, the browser window doesn't automatically update when the file on disk is updated, is there a straightforward approach to make this happen?

#

all of the work is local

elfin lance
#

you could use websockets to tell the page to reload

fossil thicket
#

@elfin lance what do i need to google?

elfin lance
#

it depends... As I only sent an abstract solution

fossil thicket
#

the workflow is - working in a python notebook, on save html report is generated, report is open in browser, i have to refresh browser to see changes

#

@elfin lance there's some context

elfin lance
#

does it have a server or do you just open the html?

fossil thicket
#

it is all local

#

so, yes, i just open the html generated into chrome

elfin lance
#

I don't think there is a way to check for changes and reload totally on the client side

fossil thicket
#

that's a shame

elfin lance
#

as webpages can't access to your hdd on demand

#

even if it is on your hdd already

fossil thicket
#

fair, i figured it might be something that people did when working on web stuff

#

locally at least

fickle fox
#

Is it possible to make role system with flask, and display some things only to people with certain role?

tender crater
fickle fox
#

Flask role menagment

#

Display certain content only to people with certain roles

round ferry
#

@versed sigil Oh!

fickle fox
#

I think thats it, thanks @tender crater

lofty matrix
#

Are there any good tutorials/books that focus on application design and infrastructure considerations for scaling to huge numbers of users?

cold anchor
#

Production Ready Microservices by Susan Fowler http://shop.oreilly.com/product/0636920053675.do - the concepts apply to non-microservices as well

Release It! by Michael Nygard https://pragprog.com/book/mnee2/release-it-second-edition - dives into all sort of crazy problems and patterns/anti-patterns of production software services

tired root
#

@lofty matrix If you have a lot of users, you need to load-balance

native tide
#

gang war

tired root
#

For a web site, this can be done with multiple methods

#

A good setup for scalability: One DB Server, one app server, one load balancer. The load balancer acts as reverse proxy. Something like haProxy.

native tide
#

I can't figure out how to go about this in a CSS file. I can only get it to work using inline style attribute on HTML elements.
background-image: url( {{url_for('static', filename='/img/image.png') }} );
Just doing the path normally doesn't seem to want to locate the static files.

tired root
#

You can multiply this setup as often as you want, at a certain point, put another load balancer in front of the whole shebang

lofty matrix
#

Thanks, for the info. Currently using a load balancer. I have some weird use cases that I was hoping to find patterns for

#

I'll bookmark those books rdbaker. Thanks 🙂

tired root
#

@native tide This needs to be relative to the css file

native tide
#

thanks. Maybe its not an option then, because I use it at so many depths in the tree. Lemme read