#web-development

2 messages Β· Page 58 of 1

outer apex
#

Which return? The first one or the second one?

viral sphinx
#

Anyone familiar with Strapi ?

#

Strapi JS

wild thunder
#

guys, pro tip:

werkzeug.security or bcrypt?

hard moon
#

Hello here

#

I have a question about frontend frameworks like Angular and React. Sometimes while setting up a project I have to run a server. I don't understand why.

#

For me, the server is involved only with backend stuff.

tired root
#

Webstuff is sandboxed, server regulates access to the files

#

gist of it

#

Browser does not allow access to the filesystem without permissiojn

#

That is why you need a development server, even for plain html and js

hard moon
#

I see

tired root
#

And why is a server only involvedf in backend stuff?

#

Who do you think sends the files over the network?

hard moon
#

And why is a server only involvedf in backend stuff?
@tired root I mean, when coding a website, only the backend is directly related to the server

tired root
#

No?

#

Serving pure HTML does not even have a "backend"

#

A Webserver such as Apache is primarily a http server, dynamic languages are plugins that tell it how to handle certain files, nothing else

hard moon
#

Ah I see now

tired root
#

Those files are still run by external programs such as php

#

or python

hard moon
#

My goal is to use Django as pure backend and combine it with React. By using start-react-app command I thought I had to handle two servers, one for Django and one for React.

#

At least for Production.

tired root
#

You need one for serving django, correct and one for serving the html with js

#

Run gunicorn in the background, only allow connections via ::1 and have an apache/nginx on front that acts as a reverse proxy with a subdomain

#

if they run on the same machine

#

Then do another vhost on port 443 with TLS to serve the user, using the main domain

hard moon
#

Run gunicorn in the background, only allow connections via ::1 and have an apache/nginx on front that acts as a reverse proxy with a subdomain
@tired root I have to admit that I don't really understand it. I use Gunicorn on Heroku and Whitenoise to serve static files. Everything else is obscure to me.

tired root
#

::1 is the ipv6 version of 127.0.0.1

#

Gunicorn does the uwsgi stuff and to protect it from bad boys, have apache at the front instead to serve your API to react

#

or nginx

#

they can be used as a reverse proxy, fetching the data from unicorn and presenting it via https

#

or whatever you are using, but yes, you need 2 virtual hosts for that plan πŸ˜„

hard moon
#

I think I'm starting to get it. But what is a reverse proxy?

tired root
#

A proxy is normally used to connect to the web for example, in companies. You first connect to the proxy and the proxy acts as your public IP

#

Reverse proxy is the other way around, the proxy acts as proxy for the gunicorn server to shield it from the public

hard moon
#

A proxy is normally used to connect to the web for example, in companies. You first connect to the proxy and the proxy acts as your public IP
@tired root It uses NAT?

tired root
#

No

#

That has nothing to do with NAT

#

This type of proxy acts on Layer 7

#

Idk how to explain it differently. YOur browser connects to the Apache, the apache connects to the uwsgi server, fetches the data and sends it via https

#

That is a Layer 7 reverse proxy

hard moon
#

Idk how to explain it differently. YOur browser connects to the Apache, the apache connects to the uwsgi server, fetches the data and sends it via https
@tired root Ah okay, I understand know

tired root
#

And that is why the uwsgi server can run on localhost, like a db

#

because it does not need public connectivity

hard moon
#

But in the end, do I really need to have to pay for two servers to build the app?

#

I wonder if it is a common practice.

tired root
#

In this case rent a vps, if you are comfortable administrating that

#

all this can run on a single server

hard moon
#

I just want a React Frontend that will connect to Django through Django Rest API.

tired root
#

But if you want to split your website into a backend with Python and a frontend with react, then yeah, you need 2 vhosts. Otherwise it would make little sense

#

A vps isn't that expensive btw

hard moon
#

But if you want to split your website into a backend with Python and a frontend with react, then yeah, you need 2 vhosts. Otherwise it would make little sense
@tired root I see, It was what I feared the most

#

A vps isn't that expensive btw
@tired root Yes maybe but for the moment I don't have the money. Maybe later.

#

It was for a small business. I want to build an online platform for gamers. I achieved the essential without Frontend Framework or API. But I wasn't satisfied by the feeling while using it. It was not as app-like as I wanted.

#

But thanks for your help, I learned new things.

tired root
#

No problem, but try setting it up at home, as practice

#

with e.g. WSL

#

or a vm if you have Windows Pro/Linux

hard moon
#

I'm mostly working on Ubuntu

gusty girder
#

which is better to learn django or flask?

tired root
#

Get libvirt, make a vm and try setting it up

#

@gusty girder There is no better

gusty girder
#

ok which one should i use

tired root
#

Django is more complete, enforces more strict ways to do things, Flask is more freeforms and has a smaller footprint, but you can load modules with stuff you are missing via addons

gusty girder
#

basically im new to web dev

tired root
#

It's up to you

gusty girder
#

hmm

tired root
#

Read about it, make a decision

balmy forge
#

If you are new to webdev, flask is more friendly as it guides you through

#

But Django is the full package

hard moon
#

I suppose that Flask gives you more freedom and flexibility than Django

tired root
#

yeah, I also find that file with the routes very weird

#

I personally like Flask better tbh

hard moon
#

I might give it a try later then. I'm mostly a Django and Node user

tired root
#

but then, I don't handle strict form rules in programming very well, one of the reasons I dislike rust

balmy forge
#

There is nothing wrong with starting out with flask / sanic / starlette / fastapi

tired root
#

I have a bit of an autistic side πŸ˜„

balmy forge
#

But if you find yourself redefining stuff django already has, it's probably time to move

#

For example ORM-like data models

tired root
#

flask-sqlalchemy

#

It's just a pip away πŸ˜„

hard moon
#

but then, I don't handle strict form rules in programming very well, one of the reasons I dislike rust
@tired root Hahaha I planned to learn Rust someday.

#

You started coding how much time ago? (Sorry if my English is bad)

tired root
#

When I was around 13. There was this German Magazine, called 64er by Markt&Technik and they always had games as listings in Basic. So I typed them down to play the games and at some point, I started getting it

#

Around 19 I got my first C++ book

#

I am 41 now

hard moon
#

Impressive, I'm only 21

tired root
#

Eh, I am not that good of a programmer tbh. I am terrible with higher level math. But I manage.

#

But then, it's just a hobby πŸ˜„

hard moon
#

Eh, I am not that good of a programmer tbh. I am terrible with higher level math. But I manage.
@tired root I'm terrible at math too XD

#

But then, it's just a hobby πŸ˜„
@tired root Cool, It's kinda my job and side hustle

#

But now I realize that its not the channel purpose

#

I'll return to my code, thanks again

cloud path
#

hey guys

#

i have an issue

#

i'm scripting a code with a variable into a flask route

#

but this variable cannot exists always, it exists only if a "if" is satisfied

#

but i have to pass the variable into the render_template

#

the problem is that if the variable exists the program works fine, but if the variable doesn't exist because the "if" is not satisfied, it doesn't work fine because i'm passing an inexistent variable

#

do you have any idea to fix that?

tired root
#

variable = None at the start of the block

#

the variable exists and can be checked if it has a value that makes sense

#

@cloud path

cloud path
#

thank you! it worked!

faint bay
#

When I build a flask web app

#

nvm

#

:"D

knotty seal
#

@faint bay I built my first flask app yesterday

#

It's pretty bad, but I'm proud of it.

faint bay
#

@knotty seal I like it ^_^

knotty seal
#

Aww. Thanks πŸ™‚

proud dome
#

CSS hover question: any idea why the first section on the left (legaltech) flickers when the hover effect resolves? both in and out ( www.thecodinglawyer.com )

this is the hover code: ```.frontimg1:hover {
transform: scale(1.05);
transition: 0.4s ;
}

.frontimg1 {
transform: scale(1);
transition: 0.4s ;
}```

native tide
#

How come I'm not able to get into vritualenv from my cmd prompt to vs code?

grizzled crescent
proud dome
#

@grizzled crescent just a small gramatical correction: 'data' not 'datas' ! πŸ™‚

grizzled crescent
#

Thx @goonhoon

cloud path
#

guys i don't manage to upload an image through flask, it doesn't return me any error but the image doesn't load itself into the folder (sorry my bad english)

#

this is the function, am i doing something wrong?

#
def save_picture(form_picture):
    random_hex = secrets.token_hex(8)
    _, f_ext = os.path.splitext(form_picture.filename)
    picture_fn = random_hex + f_ext
    picture_path = os.path.join(app.root_path, 'static/profile_pics', picture_fn)
    form_picture.save(picture_path)

    return picture_fn
#
if form.picture.data:
            picture_file = save_picture(form.picture.data)
            current_user.image_file = picture_file

and this is into the route

native tide
#

can somebody that's good with virtualenv's help me in sodium?

quick cargo
#

Im getting Error 521

#

with Nginx running and ssl working

#

as far as i can tell

#

with gunicorn running

#
server {
    listen 80;
    listen [::]:80;
    server_name crunchy-bot.live www.crunchy-bot.live;
    return 302 https://$server_name$request_uri;
}

server {

    # SSL configuration

    listen 443 ssl http2;
    listen [::]:443 ssl http2;
    ssl        on;
    ssl_certificate         /etc/ssl/certs/cert.pem;
    ssl_certificate_key     /etc/ssl/private/key.pem;

    server_name crunchy-bot.live www.crunchy-bot.live;

    location /static {
        alias /home/alevelsite/Kireina-Anime/webserver/static;
    }

    location / {
        proxy_pass http://localhost:8000;
        include /etc/nginx/proxy_params;
        proxy_redirect off;
    }
}```
#

is my current nginx config

#

Im not entirely sure how df i trouble shoot this

#

so nginx is 100% running

#

and so is gunicorn

#

yet cf says its not running pithink

zealous siren
#

Connect directly to it and see?

quick cargo
#

god i am of the confused rn

zealous siren
#

What web host do you have?

quick cargo
#

Its just on a ubuntu VPS

zealous siren
#

when I've helped friends out on this, it's hosting provider blocked cloudflare for DDOS activity

#

because all hosting provider sees is a bunch of HTTP connections from specific IPs only and nothing else

#

So I would open a ticket with provider and ask about automated blocking

#

Here is cloudflares IPs

quick cargo
#

im actually so fucking dumn

#

i accidentally deleted the DNS to the vps

zealous siren
#

that will do it

native tide
#

How come I can’t get into my virtualenv even though I type workon test (test is the name of my virtualenv)

quick cargo
#

okay nvm

#

still is going potato mode

zealous siren
#

DNS takes time to replicate and CloudFlare has to wait for TTL to expire

native tide
#

Please don’t yell at me for this question I’ve been having a shitty day so far especially in this ds server πŸ˜” But does anyone know how come I can’t get into my virtualenv even though I type workon test in my terminal window on vs code?

onyx crane
#

@native tide really sorry but wrong channel :/

quick cargo
#

normally you do <venv name>\Scripts\activate.bat

native tide
#

Oh cuz I was thinking since I’m working with django rn I thought web development would be a good place 😬

#

But where can I ask this question?

quick cargo
native tide
#

I already have a help channel, it’s dormant tho πŸ˜–

#

But I’m not trying to advertise it in anyway

#

Not making that mistake again

onyx crane
#

Django
Can anyone link me to ressources / explain on how to build choice dependent ChoiceFields ? Drop-Down1 => Select Choice => Ajax Call => Drop-Down2 updates.

All the posts i found didnt help me out.

tired root
#

All the posts i found didnt help me out.
@onyx crane If that is slang for "I couldn't just copy/paste it", then this won't help you either

onyx crane
#

@tired root wow thats a bit rude :D.

In this example the choices are defined inside the js code. I want to load the related model instances. Its often explained by the country, city example where the city options are reliant on the country choice.

=> choices cant be hardcoded in html or js, but must be loaded from the server.

tired root
#

then do a xhr to load the choices as json and go from there

onyx crane
#

whats an xhr :)?

quasi ridge
#

XMLHttpRequest (XHR) is an API in the form of an object whose methods transfer data between a web browser and a web server. The object is provided by the browser's JavaScript environment. Particularly, retrieval of data from XHR for the purpose of continually modifying a loade...

native tide
#

Hey guys

#

What's a good platform to host Django/Flask apps?

#

Other than Heroku and PythonAnywhere. Few criterias is that I need it to be:

  • Scalable
  • Cost-effective/Cheap
cerulean vapor
#

Small AWS instances can be had for free

native tide
#

I'm planning to use AWS S3 for storing user media

#

not sure about the API itself.

uncut spire
#

can anybody help me understand the tradeoff between using AWS API gateway to call lambda proxies vs writing your own API gateway in something like django or flask or quart and calling hosted APIs written in a similar framework (or maybe even something like rails, just spitballing architectures here)

#

i know they claim the cold start problem is getting better with lambdas but AFAIK the only win doing it the AWS API gateway way is getting caching for free--is that really worth it? or am i missing something else too

quick cargo
#

right

#

im a bit at a loss rn

#

Currently i cannot access the webserver

#

even tho nothing is getting blocked by firewall

#

nginx is running

#

and so it gunicorn

#

and cloudflare has the name space

#

yet im stilling error 512

uncut spire
#

gunicorn log anything funky?

quick cargo
#

nop

#

everything on the webserver is saying its running

#

ive added cloudflare Ips to be allowed by FW and even tried it with firewall off

uncut spire
#

does htop say you're near limit or something?

quick cargo
#

nop

zealous siren
#

Cf8

#

What happens when you go to hostname assigned to VPS

#

If you have containers, spin up Nginx hello world really quick

#

It’s also possible something has bound to those ports locking out your true stuff

onyx scroll
#

Hello everyone ,
I want to implement a user profile-page type system where users can go to www. Domain/username and see user info there in django. How could I achieve this?

uncut spire
#

what kind of user info

#

how many target users

onyx scroll
#

For now basic profile information

Username
Account creation date
And user inputted data

#

I want every logged in user to be able to see it , I'm aware I need a protected route for this

uncut spire
#

yep

#

then define a profile view with a route in urls.py with something like 'home/<slug:username>' if you want the path to be username

onyx scroll
#

Ok, anything else?

uncut spire
#

you can use the models.User class in your models.py

#

and subclass it to extend later if you'd like as opposed to just using it out of the box, which is my recommendation

#

put the logic for querying relevant data

#

unsure what your scale is or database choice is, but generally this is pretty symmetric

#

across those options

#

write your template first (or whatever your actual static rendering will be) so you have an idea of what you'd like to display, then fill it up from the backend

#

view may look somethign like

class HomeView(generic.detail.DetailView):
    template_name = 'home.html'
    model = User
    context_object_name = 'user_items'

    def get_object(self):
        return Item.objects.filter(item_owner=self.request.user)
#

if you want to use function-based views, it's easy too, but my recommendation is to just use CBV

onyx scroll
#

Alright, thanks

uncut spire
#

np gl

quick cargo
#

@uncut spire im gonna try just remove the site from CF

#

and try access it directly

#

even tho it was working before originally

uncut spire
#

i imagine you saw the 512 in browser, did thhe nginx access log reflect that?

#

or error log?

quick cargo
#

how can i get the nginx log?

uncut spire
#

where does the failure occur server side is your first mission

#

/var/log

#

somewhere in there usually depending on your config

quick cargo
#

which log should i be looking at

#

xD

#

oh wait

#

nvm i completely didnt read the big blue text saying nginx

uncut spire
#

probably start with access

quick cargo
#

hmmm

uncut spire
#

do you see a 512 in there

quick cargo
#

i dont appear to have a log called access

#

and nginx is apparently empty

uncut spire
#

/var/log/nginx/access.log

#

oh

quick cargo
#

hmm

#

wait nvm

#

access has shown up

uncut spire
#

in /etc/nginx/nginx.conf, can you tell me your lines for access_log and error_log

#

ah ok

quick cargo
#

ohhhhhhhh i did an oof

#

i did a really biggg oofd

uncut spire
#

?

quick cargo
#

i very nearly forgot to re-enable ssh after firewall reset

#

fuck me that could of hurt

uncut spire
#

haha yes

#

but you only nearly oof'd

quick cargo
#

i had a breif moment of going "oh fuck i logged out"

zealous siren
#

your DNS just crashed

#
Resolve-DNSname : www.crunchy-bot.live : DNS name does not exist```
quick cargo
#

hmm

#

try now?

#

idk if it was because it was changing name servers

zealous siren
#
Resolve-DNSname : www.crunchy-bot.live : DNS name does not exist```
#

I'll wrap into a loop

quick cargo
#

well this is another amazing thing to go with this other stuff

#

I remember now why i chose not to deal with the website deployment on another site xD

zealous siren
#

if you want to watch yourself and running Powershell

#
while($true){Resolve-DnsName www.crunchy-bot.live -Server 8.8.8.8;sleep 5}```
quick cargo
#

i am

#

dns gone poof

zealous siren
quick cargo
#

hmm yh probs

#

lemmie try the other domain

#

if i can find what registra it was

zealous siren
#

did you rotate your NS away from cloudflare?

quick cargo
#

its still on CF atm

zealous siren
#

just pointed the A record towards your VPS directly?

#

your code isn't open source is it?

#

I wanted to steal your NGINX.conf and shove into nginx container to see if I could replicate the issues

quick cargo
#

the code is open source but the nginx config isnt there

zealous siren
#

you posted it earlier πŸ˜›

quick cargo
#

legit atm

#
    listen 80;
    listen [::]:80;
    
    server_name crunchy-bot.live www.crunchy-bot.live;

    location /static {
        alias /home/alevelsite/Kireina-Anime/webserver/static;
    }

    location / {
        proxy_pass http://127.0.0.1:8000;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection 'upgrade';
        proxy_set_header Host $host;
        proxy_cache_bypass $http_upgrade;
    }
}```
#

this is what a friend suggested

zealous siren
#

hit me with your github

quick cargo
#

ignore the mess lol

zealous siren
#

and you use nginx for proxy and gunicorn for actual python

quick cargo
#

yup

#

btw this is the dns

zealous siren
#

I'm firing up my development laptop now

quick cargo
uncut spire
#

when you tail the access log, do you see a 512

quick cargo
#

i get litterally nothing lol

uncut spire
#

and what is your access_log in your top level config

#

/etc/nginx/nginx.conf

quick cargo
#

it does appear to be set to access.logs

uncut spire
#

check the error log

#

can you post the tail of it?

#

if there is anything that is

quick cargo
#

both are apparently empty

uncut spire
#

ls -al on them, maybe they're piping to stdout or something funky

#

via some symlink nonsense

#

let's also try kicking nginx to start this off: sudo nginx -t && sudo systemctl restart nginx

quick cargo
#

mhmm

#

status ok!

zealous siren
#

so restarting nginx fixed it?

quick cargo
#

no

#

it still doesnt bind to the address

#

but nginx is just saying nothing is wrong and its running

uncut spire
#

wait 521 not 512 http error...

#

ah

quick cargo
#

cloudflare 512

#

XD

zealous siren
#

you don't have anything for nginx do you

#

and what is your gunicorn start command?

quick cargo
#

gunicorn -w 5 main:app

zealous siren
#

got it

uncut spire
#

do a sudo ufw app list jusut to make sure you have all apps available

#

sorry i need to go through the standard dumb checks before anything crazy

quick cargo
#

yeah its fair enough

#

im going crazy already lol

uncut spire
#

looks good

#

did you configure nginx to handle ssl?

quick cargo
#

its on a flexible cloudflare ssl or whatever

uncut spire
#

right

quick cargo
#

so for me its still http (bad ik but just want to have a working https test bed)

uncut spire
#

yeah no worries, common initial proceedings

#

but your nginx conf listens on :80

#

https port is 443 and i get redirected to https when i try your site on http

#

im not an nginx expert but i need that to make sense in my head, right now it doesnt

zealous siren
#

his earlier nginx had SSL files

quick cargo
#

yeah

uncut spire
#

ah

nimble epoch
#

Hi everybody

quick cargo
#

i tried setting up nginx with and without ssl cert

#

shall i add the 443 stuff for nginx rq?

uncut spire
#

something like ssl on; ssl_certificate /etc/ssl/certs/cert.pem; ssl_certificate_key /etc/ssl/private/key.pem; ssl_client_certificate /etc/ssl/certs/cloudflare.crt; ssl_verify_client on;?

nimble epoch
#

I know Pure sqlalchemy and flask_sqlalchemy which one is better to use with flask? Or no difference?

quick cargo
#

last i checked it wasnt any diffrent as Cs other some minor functionality diffrences

#

btw for me, when i did ssl i just had cloudflare on full, so no cloudflare crt

zealous siren
#

flask_sqlalchemy is probably better integrated

uncut spire
#

+1 on rabbit's response, you're probably going to wind up retreading the implementation but YMMV

#

so at some point you have to listen 443 ssl http2; listen [::]:443 ssl http2; no? im for sure missing something here if not

quick cargo
#

yh

#

let me add it back qucikly

uncut spire
#

it may be i'm just not familiar with cloudflare's offerings if not

#

ok

zealous siren
#

your requirements are only flask/flisk?

#

gunicorn isn't required?

quick cargo
#

i installed it separately

zealous siren
#

SRE Face: yert

quick cargo
#

xD

#

i still gotta make an entire DB orm for this project if this freaking domain doesnt kill me first

uncut spire
#

lmao rabbit

#

im also not sure how the client cert is unneeded

quick cargo
#

full on cloudflare is self signed ssl iirc

uncut spire
#

ah gotcha

quick cargo
#

im not sure if i understand this fully

#

but the way im understanding how flexible works

zealous siren
#

Flexible means it tries to encrypt but if it can't, it won't

quick cargo
#

is its https between CF and the browser

#

and http between CF and server

zealous siren
#

HTTPS between CF and web server

#

let's build a container

quick cargo
#

yeah im up for building a container lol

zealous siren
#

also, why nginx

quick cargo
#

idek

#

first choice when deploying it with gunicorn ig

#

had the most support for it when i was searching lol

zealous siren
#

this is one fat pythong container

quick cargo
#

😳

zealous siren
#

well, It's somewhat working locally

#

I'm getting empty response

quick cargo
#

hmm?

zealous siren
#

is there some directory for webserver

#

like server/api?

quick cargo
#

<address>/home should be an endpoint

zealous siren
#

empty response from gunicorn container

#

I'm pretty sure I'm missing libraries

quick cargo
#

the only dependancies are flisk and flask for python

#

wait

#

fuck

#

did i forget the css framework

#

not that should affect the original deployment i dont think?

#

hmm no

zealous siren
#

you could have API that JS calls to gather the data

quick cargo
#

somthing like JS calling a python api to get the data to make the charts ig

zealous siren
#

CF8

#

progress

hidden cairn
#

maybe it just a client side thing and im just trying to shoehorn python into this

quick cargo
#

πŸŽ‰

#

thank god i havent stopped it using the css cdn atm lol

#

otherwise it would a rather ugly looking page

#

xD

zealous siren
#

that's using Flask

#

now let's see why gunicorn hates it

quick cargo
#

before i tried to https it it was alright with it

zealous siren
#

BTW, this is why git is useful even for config files πŸ˜„

#

opps

#

ROLLBACK ROLLBACK!

quick cargo
#

yeah lol

ornate solar
#

anyone know much about sockets and integrating some type of socket server with a Flask web server? I don't mean websockets I mean normal sockets.

uncut spire
#

what's wrong with nginx?

quick cargo
#

huh?

uncut spire
#

i just saw a "why nginx" and i'm curious

zealous siren
#

nothing

#

but gunicorn is production ready

#

so if they are not proxying anything out of nginx

uncut spire
#

@ornate solar yeah you just doing a Flask app.run somewhere? gunicorn is a pretty battle tested

zealous siren
#

yep

quick cargo
#

do i even need nginx?

zealous siren
#

unless you are having nginx host something no

ornate solar
#

@uncut spire yeah i use gunicorn on my production server but don't want the socket server be able to interact with the flask server

uncut spire
#

wait are you just running gunicorn in the background? i dont understand your use case then

#

you want to keep your socket server, i.e. gunicorn, to not interact with a flask server (do you mean development server? this is confusing)

#

in any case, one would want to create /etc/systemd/system/gunicorn.socket to be something like ```[Unit]
Description=gunicorn socket

[Socket]
ListenStream=/run/gunicorn.sock

[Install]
WantedBy=sockets.target```

#

then you need ot make a choice of systemd supervisord etc

#

and run your daemon from there

ornate solar
#

whats the easiest way to have them interact with each other

zealous siren
#

that's in gunicorn docker container

quick cargo
#

nice

ornate solar
#

@uncut spire i only use gunicorn in my production server

#

so my dev server is just the simple dev server that flask provides

uncut spire
#

when you say "them interact with each other" my confusion is what the two ends of that interaction mean to you

zealous siren
uncut spire
#

do you mean dev server and prod server? they should never really interact

zealous siren
#

got it running on port 80

quick cargo
#

so basically we can just yeet this nginx stuff

#

which makes shit so much simpler tbh

ornate solar
#

i want the socket server and flask server to interact

#

like accessing the db and stuff like that

quick cargo
#

what db r u using

#

most support sharding or multiple instances in most cases

zealous siren
#

CF8, DM?

quick cargo
#

sure

zealous siren
#

I'm wrapping up

uncut spire
#

@ornate solar read https://www.digitalocean.com/community/tutorials/how-to-set-up-django-with-postgres-nginx-and-gunicorn-on-ubuntu-18-04 and follow that kinda deal, let me know if you run into trouble

DigitalOcean

Django is a powerful web framework that can help you get your Python application or website off the ground. Django includes a simplified development server for testing your code locally, but for anything even slightly production related, a more secure

ornate solar
#

this is something more what im looking for

#

but im using normal sockets, the client is going to be just a normal python program not a browser so thats why i dont think websockets work in my case but im not really sure

uncut spire
#

that looks like websockets

wary gate
#

"i'm not interested in websocket, i'm interested in websockets with socketio"

#

jk that just looks like a websocket wrapper to me

ornate solar
#

im prob just gonna separate the flask server and socket server

uncut spire
#

so sockets and websockets are different concepts, i recommend reading more about each one

wary gate
#

Here's a stackoverflow with some distinctions, for reference:

ornate solar
#

i got that but all the libs that work with flask are for websockets

#

i cant find one for normal sockets

#

do libs like flask_socket and flask_socketio work with normal sockets?

zealous siren
#

normal sockets is not longer web

#

I got CF8 his dockerfile but I'll reproduce it here so poundcake can see

#
FROM python:3.8
WORKDIR /usr/src/app
COPY requirements.txt requirements.txt
RUN pip install -r requirements.txt
COPY ./ ./
RUN ls -R
ENV GUNICORN_CMD_ARGS="--workers=5 --bind 0.0.0.0:8000"
CMD ["gunicorn", "main:app"]
#CMD ["python3", "main.py"]```
uncut spire
#

LGTM

#

@ornate solar so no, a websocket is something someone might use for setting up like a chat or streaming feature in their application, it doesn't relate strongly to the concept of regular ole "sockets." a regular socket is, roughly speaking, a bundle of an IP addr, a port number, and a transport protocol like TCP. in your context, it is more likely that you would use something like supervisord or systemd to manage socket and service files for your application, effectively running gunicorn for you. if you wanted something like chat, you would use websockets in your actual python code, using that connection to send and receive data instead of configuring how your application is run

ornate solar
#

its just for communicating from my local server at home to my digital ocean server

#

no browser stuff which is why it has to a normal socket but the only libs out there that work easily with flask are for websockets

uncut spire
#

what is the purpose of the communication

ornate solar
#

home automation

#

so controllers connect to the main ws that is talking to the local server

uncut spire
#

what data needs to be transferred from local server to digital ocean is what i'm trying tto understand

#

this is starting to sound like it needs something other than websockets, depending on payload

ornate solar
#

status of devices on the network

uncut spire
#

give me an idea of size and rate of transfer please

#

like an 'OK' every 5 seconds?

zealous siren
#

websockets work

uncut spire
#

for sure, but are likely overkill

ornate solar
#

but websockets are only for the browser

quick cargo
#

no?

zealous siren
#

no, devices can use websockets

uncut spire
#

n they are not

ornate solar
#

oh

uncut spire
#

but you may not need or want something tthat heavyweight

quick cargo
#

tbf wouldnt a simple REST api work

uncut spire
#

^this is what i'm trying to understand

zealous siren
#

websocket is method of transport, it runs over HTTP like setup but it's a socket

quick cargo
#

like one of my api's can easily take 500 requests a sec and on one of our others it handles 30k+ a sec 🀷

ornate solar
#

it could work but it would be nice for instant communication

uncut spire
#

what does "instant" mean to you

quick cargo
#

REST apis can still be "instant"

zealous siren
#

alot of IOT devices use websockets because it's easy to setup

uncut spire
#

this is why i was asking about payload size and rate πŸ™‚

#

also, what needs to be done with said data? does it just need to be displayed?

ornate solar
#

so the local server would be pinging every 5 sec which would be better to be like .5 sec delay

zealous siren
#

and firewall/routers are familiar with them

quick cargo
#

how big the payload tho

ornate solar
#

not very big

uncut spire
#

just status, i bet it can just be a string

quick cargo
#

surely a rest api would work then

ornate solar
#

it was going to just be a string of json

#

should i just ping the server every 1 sec

uncut spire
#

that is one option. another option is use something like daphne to serve a websocket if you would like to go that route

quick cargo
#

isnt a ws a lil heavy weight tho for this

uncut spire
#

we're trying to get you to the best answer here

#

agree, sending a string every .5sec or even .1 sec is doable with a simple flask endpoint in a local network if you want to set up the polling for it

#

but again, really need to know what is being done with said data before recommending any optino

quick cargo
#

yh

uncut spire
#

also, this connection does not need to be duplexed--correct?

#

one way reads?

ornate solar
#

duplexed?

#

yeah

uncut spire
#

ok

ornate solar
#

i was thinking of using a socket so the server can instantly send commands to the local server

quick cargo
#

once again what is "instant" to you

ornate solar
#

less than .5 sec

#

which is doable with normal sockets

uncut spire
#

you can use a socket as well--let's finish up what needs to be done with the data

ornate solar
#

something like {type: cmd, dev_id: 1, status: off}

quick cargo
#

i feel like REST might be the best choice looking at the size of his data

#

and the speed needed

#

i feel like a WS is a lil heavy for just that

uncut spire
#

no need for websockets or rest in all likelihood

#

so what gets done with tthis data

ornate solar
#

the local server would see that its a command, find the device from the device id, and turn it off

#

but with REST, the local server would have to be getting the main server every second

uncut spire
#

so, the connection does in fact need to be duplexed. data is going back from computer B to computer A

ornate solar
#

yeah in a perfect world

uncut spire
#

okay important detail right there

ornate solar
#

but u can do that with a normal rest api but it would be slower

#

and i dont want to overload my droplet

uncut spire
#

another important detail. what are theparameters of your droplet

ornate solar
#

the lowest... one sec

uncut spire
#

1TB of transfer

ornate solar
#

wdym

uncut spire
ornate solar
#

yeah thats it

uncut spire
#

ok

#

so probably use vanilla sockets after all--no websocket needed, no rest API needed, you need to be kinda skinny on transfer just to play it safe

#

something like ```import socket

s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)

s.connect(("localhost", 5000))on the client side and
import socket

s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)

s.bind(("localhost", 5000))``` on thhe server side

#

you need to manage your s.recv and s.send pretty carefully to meet the specifications you gave

ornate solar
#

yeah i got the hello world working and not am trying to work it with the flask server

uncut spire
#

why do you need flask

ornate solar
#

is there no way to combine them

quick cargo
#

if you're gonna have a flask server you might aswell just have a endpoint and use a REST api

uncut spire
#

what i'm asking is why do you need to involve flask at all?

native tide
#

python manage.py makemigrations appname this line strictly makes the migrations file (e.g. 0007_auto_20200510_1745.py) and that's it, right? it doesn't do anything else as long as i have not yet run python manage.py migrate?

so if i want to in effect cancel the migration and make further changes to my model, then can i just simply delete that migration file?

quick cargo
#

i wouldnt just delete them

#

it can bug out like that

#

just do makemigrations again after changing / reverting stuff

ornate solar
#

@uncut spire my flask server has all the auth logic, user management, db stuff

native tide
#

@quick cargo ok ty

ornate solar
#

so an endpoint on the flask side can sent a command through the socket to the local server

quick cargo
#

but...

#

why would you have a completely separate socket server when you already have a webserver running

#

instead of just having another endpoint

ornate solar
#

i dont want a separate socket server

uncut spire
#

ok so logic of exposing home automation software via a non-closed network aside, what it sounds like you want is basically socket-communication as a service, and now we're right back to REST unless you want to do socket-as-a-service in the background or something

#

it now seems best to just run a minimal rest endpoint as @quick cargo mentioned

rustic pebble
#

So you want a flask server that is also a socket client server at the same time?

ornate solar
#

yes

uncut spire
#

you'll need a GET and POST on each of those it seems

#

i find that inadvisable

#

but maybe someone has done something similar and please bonk me on the head with your knowledge if that's the case

quick cargo
#

i wouldnt go through the effort of doing all that

#

considering it'll probs be slower than just another endpoint

uncut spire
#

it's just so much less work and you're already running the webserver so I don't see tthe point of it being asymptotically less network traffic

rustic pebble
#

You can use aiohttp and async to make a server that acts both as a socket client and http server

ornate solar
#

with the rest option, the local server would have to GET some type of new_command endpoint every second

quick cargo
#

and?

#

my rest api can handle upto 30,000 requests a sec

rustic pebble
#

@quick cargo local?

quick cargo
#

even running on my development server it can handle over 500 a sec without breaking a sweat

uncut spire
#

no need for async yet, think this is still a wtf-do-i-use 10000 foot conversattion

quick cargo
#

yh

#

and async can cause more issues than good

rustic pebble
#

It depends on how you use it

uncut spire
#

well it can also be a huge perf boost

#

but it's not relevant yet in any case i believe

rustic pebble
#

Yup

uncut spire
#

i just saw yesterday how nice quart can be

rustic pebble
#

Quart is good but aiohttp is the real deal

#

πŸ™‚

quick cargo
#

nah

#

aiohttp server's are slow

rustic pebble
#

It depends

quick cargo
#

and annoying to scale

rustic pebble
#

On how you use them

quick cargo
#

if you are gonna go async do quart

rustic pebble
#

Quart does not support many flask modules though

quick cargo
#

because blocking

rustic pebble
#

Yup

quick cargo
#

you shouldnt be using flask modules for async stuff because most of it is sync

ornate solar
#

what about native threading?

quick cargo
#

why?

uncut spire
#

what about it

rustic pebble
#

It is impossible on python

#

due to GIL

ornate solar
#

ive got my dev server to use threading to make daemons

rustic pebble
#

Is it python based?

ornate solar
#

it doesnt work on my prod server and i know i should use something better

#

yeah

quick cargo
#

you can make daemons with python

#

tho its a bit

#

unsafe

rustic pebble
#

Yes

#

Tbh if you want multiprocessing and scaling you could just use celery

#

Or docker/kubernetes

ornate solar
#

i looked at celery

quick cargo
#

k8s scaling in awsome

rustic pebble
#

Yeah

#

Celery is a mess to setup

quick cargo
#

not that any of this helps his original question lol

uncut spire
#

well tbh

#

it sounds like he just needs a GET and POSTT

quick cargo
#

yh

rustic pebble
#

What does he want to do again?

ornate solar
#

that

quick cargo
#

rest api

#

just slap and extra endpoint on

rustic pebble
#

that sounds like webserver is a proxy

quick cargo
#

dont make a WS for the sake of making a ws

#

also

#

if that is acting like a proxy

uncut spire
#

no websockets, he's talking about import socket stuff

ornate solar
#

^

quick cargo
#

wouldnt (god forbid) nginx do that for him

uncut spire
#

n

quick cargo
#

he says after having 12 hours of litteral hell

uncut spire
#

something like daphne

#

i've done websockets witth daphne before it's quite stable

rustic pebble
#

I am not sure what a webserver does in this scenario though

uncut spire
#

that's what i'm sayin

rustic pebble
#

If this is IoT you can use a serverless solution

ornate solar
#

the webserver would be the interface for the controllers

uncut spire
#

but like

#

why

#

lol

quick cargo
#

^

rustic pebble
#

I would make this serverless

uncut spire
#

^

quick cargo
#

just cut out the middle man lol

rustic pebble
#

Replicating amazon lambda

#

And you can contact your devices directly

uncut spire
#

^^^^

#

yo phone be a computa too

rustic pebble
#

Ya

uncut spire
#

do them beep boops device to device

#

dont let me sniff your network traffic lol

#

it's all one network right? you aint runnin some multiple-network home wifi right?

rustic pebble
#

The only reason a webserver is needed is if the traffic between your webserver and localserver should be encrypted

#

and you want to create a distribution network

#

But like thats too much to make to control a fridge and a tv

uncut spire
#

and even if you want a nice frontend for it, just make an android/iphone app that does everything on the LAN

rustic pebble
#

On React Native

uncut spire
#

it's not so bad

rustic pebble
#

So you never exit that web based development

quick cargo
#

@rustic pebble just use your Samsung smart fridge to interact with the server to turn on the tv

rustic pebble
#

5HEAD

uncut spire
#

it's important to note that we're not just putting you down needlessly @ornate solar , it's just you're shoehorning a webserver in there needlessly from the info you've given us

rustic pebble
#

You will essentially have 3 different servers when you can literally do it in one

#

Webserver, local server, device server

#

lel

quick cargo
#

fuck

#

wrong

#

cri

rustic pebble
#

I am making a huge app for a game (Valorant)

#

I will supercharge it with features

ornate solar
#

@uncut spire im looking in designing a home automation system and already have my webserver set up for other reasons. I'm just trying to figure out how to control the system remotely

rustic pebble
#

Why can't your devices connect directly to the web server?

ornate solar
#

some just can't

rustic pebble
#

What is limiting them?

ornate solar
#

their design?

#

idk they just dont

#

like a chromecast

rustic pebble
#

If they can connect to localhost they can connect to internet as well

#

I don't know why you would want a chromecast over the internet

#

It has terrible latency anyways

ornate solar
#

yeah im just gonna make a simple rest server for the remote connection

rustic pebble
#

Are there chromecast sdk tools?

quick cargo
#

btw, Thanks @uncut spire @zealous siren I havent got it running on https yet but im gonna sleep and deal with this on a fresh head, Atleast its not dockerized!

uncut spire
#

πŸ‘ here if it needs some helping

quick cargo
#

it is dockerized**

rustic pebble
#

What are you making?

quick cargo
#

im attempting to just move a test server onto https

#

cuz oauth2

#

and its proven to be the biggest pain in the ass out of everything including making constants in python

rustic pebble
#

You can forward the domain on cloudflare and get free ssl in 5 mins

quick cargo
#

what we've been doing

rustic pebble
#

lmao

quick cargo
#

however it decided to go potato mode

rustic pebble
#

Normal, browser cookies

#

How you set a cookie?

#

It depends

#

For example here I am using a cookie to save the user state so I can know which user just signed in

#
def callback_wrapper(code, DISCORD_CLIENT_ID, DISCORD_CLIENT_SECRET, URL):
    token = get_access_token(code, DISCORD_CLIENT_ID, DISCORD_CLIENT_SECRET, URL)
    user_data = get_user_data(token)
    res = make_response('')
    res.set_cookie('user', data_to_jwt(user_data), max_age=3600)
    res.headers['location'] = url_for('index')
    return res, user_data
#

This contains a json web token that came from a dict which contains stuff like user_id and user status

#

The example above is not a normal login

#

It is using OAuth2

#

It is the login with discord implementation

#

Using services that supports OAuth2 is the safest

#

I am not sure

#

I always use OAuth2 as it empowers you to add things like Login with Apple Login with Facebook Login with gmail

#

np

kind sonnet
#

Ok so im going to aim to get a job as web developer and i want to start with Django. I wanted to ask if there are is anything else i should possibly learn

uncut spire
#

an entire stack

rustic pebble
#

Well you can learn web frameworks like React, Vue, Angular

#

node

#

multiprocessing

#

web apps

uncut spire
#

and a db like mongo/postgres

rustic pebble
#

stateless apps

#

sql, nosql

kind sonnet
#

As well as html,css,js

uncut spire
#

and know how to code outside your framework, too many devs that are lost outside of their framework

kind sonnet
#

I can code in python so..

uncut spire
#

that'll do it

kind sonnet
#

Ok ok

#

Ill just get a better understanding from some research

uncut spire
#

work through the django docs, deploy a django website to some free AWS or something, know how to deploy and manage a db (do some migrations etc)

#

just experiment... it's the common theme of successful devs

kind sonnet
#

Im using sqllite at the moment

uncut spire
#

good enough to start πŸ™‚

kind sonnet
#

Wats apache

uncut spire
#

apache and nginx will actt as proxy servers for your static content, to put it very simply

#

you should read about both, they are both widely used

kind sonnet
#

Ok ill start with node

#

And react

rustic pebble
#

I wouldn't suggest starting with react

kind sonnet
#

Than go from there

#

Ok nodeπŸ˜‚

rustic pebble
#

Do you already have normal html/css/js knowledge?

kind sonnet
#

Yes

rustic pebble
#

Node isn't really something hard you learn it as you go

#

I would use Vue if I were to get started on a frontend framework

kind sonnet
#

Tho my css needs a little work

#

Ok

#

Baby steps

rustic pebble
#

Yea take it slow and you will get good at it

#

Once you are comfortable working around components

#

Then react will seem easy

kind sonnet
#

Im fully commited so ill work on them 5 days a week

#

There is nothing else to do anyway

rustic pebble
#

Yea haha

kind sonnet
#

One last question

#

What is this centering a div that i keep hearing about

rustic pebble
#

?

#

No idea haha

kind sonnet
#

O well ill come across ot eventually

#

Once i spent 3 years on this i hope i can use it for something πŸ˜‚

rustic pebble
#

Haha

#

It all comes down to personal will

kind sonnet
#

Im fully commited

rustic pebble
#

Well then you got a career possibility in front of you

kind sonnet
#

I started learning python 4 months ago

#

And i can read,code and underatand it

rustic pebble
#

That is good

#

Although you will find web development vast

#

Since you have to deal with way more things that just one language

kind sonnet
#

But django feels like a completely new thing

rustic pebble
#

I have never used, will never use django

#

I find it very bloated and time consuming

#

I use React to build my websites

kind sonnet
#

I wanted to use flask at first but chose django in the end

rustic pebble
#

flask is better imo

kind sonnet
#

Ill get to it eventually

#

Iys just difficult doing these things alone

rustic pebble
#

Sometimes it can get harder working in a team

kind sonnet
#

My friend is doing a course on web develoment but he cant help me unless its with css

#

@rustic pebble how so

rustic pebble
#

Because you are not allowed to express your thoughts as you want which can make you irritated

kind sonnet
#

I dont even know why i chose to learn python

#

I origanally wanted to be a software, game developer

rustic pebble
#

Because it is probably dynamically typed, interpreted and easy to learn

kind sonnet
#

O yeahπŸ˜‚ πŸ˜‚

#

I picked up java aswell along the way

rustic pebble
#

Java is so bad imo

kind sonnet
#

But it was so time consuming

rustic pebble
#

Java and PHP are the languages I don't know which I'd shoot first

kind sonnet
#

I was writing 6 lines to print hello world

#

I also picked up php

#

Java was more fun

rustic pebble
#

In their defense they both belong/come from the C-family

#

Every language is like that there

kind sonnet
#

Php was easier then python but more annoying

rustic pebble
#

php is strongly a server language

#

python is the second best language for everything

kind sonnet
#

Another reason i picked it

#

Well at least one game came out of python

rustic pebble
#

But tbh, at least in my opinion, if I were to start now I would pick Golang

kind sonnet
#

Wat is that

uncut spire
#

lol no generics

rustic pebble
#

golang is another language

kind sonnet
#

Anyway where can i find a good html template

rustic pebble
#

lmao

#

literally google

#

free html responsive template

#

I have started on a rough design for a metasearch engine

#

I am making

kind sonnet
#

Ok so thats sorted

uncut spire
#

kiwi what's this valorant site you're making

rustic pebble
uncut spire
#

no

rustic pebble
#

Well it is a metasearch engine for league of legends

uncut spire
#

i play dota, is it like dotabuff? stat collection etc?

kind sonnet
#

Time to open that js text book

rustic pebble
#

Yea

#

It is like dotabuff

#

I am going to make it very advanced

uncut spire
#

amazing man

rustic pebble
#

Currently designing it but I will superload it with features

#

I have like 2-3 months to make it

#

Before valorant gets released

uncut spire
#

are you working with riot?

rustic pebble
#

No

#

It is just a possibly opensource project for my resume

kind sonnet
#

I hope to make a site like that one day

rustic pebble
#

Yea it is not going to be difficult

#

I expect huge load

#

I have huge plans for that service

#

desktop app, mobile app, website

kind sonnet
#

I would love to read your code

rustic pebble
#

I am going to do it on react typescript

#

so idk how much you can understand out of it

kind sonnet
#

😫

#

Never mind

rustic pebble
#

If I opensource it I will probably post it on the opensource channel here

#

But I am not sure whether I will build anything on python at all

#

I am thinking of a huge stack.
ReactTS for website
c# for windows app
electron react for macapp
react native for mobile devices

kind sonnet
#

Dang

#

Your talking to someone who still sees that as impossible to achieve

rustic pebble
#

Nothing is impossible when you are coding

#

And that is what keeps me going

#

I like putting challenges to myself so I keep me motivated

#

If I were to stick with the same technologies I would be bored by now

quasi ridge
#

decrypting a properly-encoded one-time pad message otta be impossible πŸ™‚

kind sonnet
#

I dont thibk imma learn the hard language

quasi ridge
#

quickly factoring the product of two thousand-bit primes otta be impossible

kind sonnet
#

Like c++

rustic pebble
#

Technologically impossible or programmatically impossible?

warm igloo
#

@rustic pebble Why C# on Windows if you’ve already built it in electron?

#

Just for portfolio builder?

rustic pebble
#

^^

#

C# should be able to interact with the client api directly

warm igloo
#

Of course. You can build it once in react, for web, then most (if not all) will work wrapped in electron. No need for platform specific versions.

But as a portfolio builder sure why not? Flex multiple skills.

rustic pebble
#

Yeah, I am 18 this will look amazing for internships

warm igloo
#

πŸ‘

#

I’d appreciate it as a hiring manager.

#

The more code you can share with me the better.

rustic pebble
#

I can’t give more info but it will be the most advanced meta search engine ever

#

So you bet this will have loads of code

warm igloo
#

That’s ... ambitious.

#

πŸ™‚

rustic pebble
#

I have built many things revolving around websites and webapps

#

I am very confident I can build it

warm igloo
#

What is your data store? A search engine needs a fast data layer.

rustic pebble
#

Dynamodb

#

I am probably going to use Amazon Lambda as a solution for it

quasi ridge
#

you'll get a job quickly

#

those are rare skills

rustic pebble
#

I already work part time

#

For a good amount of money

warm igloo
#

I haven’t thought about interns for this summer with the lockdown and such. Hmm. I should probably do that.

rustic pebble
#

Yea , I am planning to intern at a bigger company once I am done

#

Probably move to US as well

#

My goal is to study AI but it has to wait for now

warm igloo
#

Good luck. πŸ€

rustic pebble
#

Thanks!

upbeat storm
#

can anyone help me with web development

ebon gull
#

Maybe depends on your issue

#

@upbeat storm

upbeat storm
#

too late dude

ebon gull
#

My bad

upbeat storm
#

hey

#

!close

#

anyone literally anyone

quick cargo
#

what

tender crater
#

Does anybody have any experience scheduling periodic tasks on Celery (working in Flask)? I have correctly set up a periodic task but the crontab schedule seems to be ignored: instead of running every hour the task runs every 10 seconds:

 CELERYBEAT_SCHEDULE = {
    "check_istop_hourly": {
        "task": "tasks.update_is_top",
        "schedule": crontab(hour="*", minute="1"),
        "args": ()
    }
}
gusty girder
#

hello anyone here?

quick cargo
#

whats up

gusty girder
#

ok so are there any good tutorial on flask

quick cargo
#

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

The code for this series can be found at:
https://githu...

β–Ά Play video
#

goes through just about everything from setting up to database to deployment and ssl etc...

gusty girder
#

cool

#

but then hes teaching to build a blog right

quick cargo
#

you can use the same principles with your own stuff

#

no matter what site it is, it still follows the same basic paths

gusty girder
#

but then

#

he doesnt cover on using templates from google

#

or does he

#

@quick cargo the problem is i have downloaded some templates from google but dont know how to use them

quick cargo
#

what does your project folder look like atm?

gusty girder
#

huh?

somber wedge
#

Hello

#

Can anyone tell me how to validate a POST request using flask with firebase auth?

quick cargo
gusty girder
#

yes

quick cargo
#

by default the static and templates folder are supposed to be in the same folder as the main file

somber wedge
#

I want to make a backend which serves normal get requests and secure post requests for adding content.

quick cargo
#

to render some google template its the same as if you did it with that blog example

#

e.g

#
def home():
    return render_template("index.html")```
gusty girder
#

but to edit it ive to mess up with the html right

quick cargo
#

yh

#

you have todo that anyway to tinker with it

gusty girder
#

do i need to learn html for that?

#

and btw are there cool templates for free

quick cargo
#

yeah if you want to edit the pages no matter what you do you'll need to learn some html and css

#

it doesnt take too long tbf

gusty girder
#

ok

quick cargo
#

@somber wedge Use somthing like Oauth2 then depending on ur backend lib its fairly easy to implement

native tide
#

who used Netlify before or uses it?

#

I want to know if it's good to use it

fickle fox
#

Hey guys, I was wondering how can I upload images and post them in my "forum", image should be postablr anywhere in that post, i am looking for some docs or myb tut

vague vigil
#

Hi all, I'm a data scientist currently working as sole engineer for a company. I'm building a Dash web app, but have essentially no experience with web development.

I have a dockerized dash app that runs great locally, slow as hell when deployed on azure. It uses google vision OCR to get text from data, then performs some NLP on the text. Logs show the function to get the OCR results is a bit slower on the deployed app than the local app (2-3 seconds vs 1 second), but nothing awful. I checked my network tools and it shows a 21 second round trip time (client-server-client) with the deployed app, so that seems to be my problem.

#

Dash has client-side processing using javascript, which looks like it may be the way to go. My problem is that since I use google vision OCR I need credentials. Can I safely hand that info to the client somehow so that it communicates directly with google cloud? Ideally something that can be implemented in flask.

rustic pebble
#

@vague vigil Sharing credentials in any shape or form with the client app is a big no no. What you can do is create an api route that gets called and executes the function afterwards

vague vigil
#

Much appreciated, Kiwi. I'll take credential sharing off the table of possible options.
What you can do is create an api route that gets called and executes the function afterwards
This is possibly a dumb question - I really am quite ignorant around this stuff: is this different from what I'm currently doing? Currently I click and drag to select points. When I release the click, it fires a callback that does the following on the back end:

  1. select pixels within the range of the selected points (box select)
  2. send that part of the image to google OCR
  3. receive the text from google
  4. run the text through an NLP classifier
  5. create a dash datable from this text
  6. return the table

It's currently this process that takes ~2 seconds on a docker container run locally and 10-45 seconds when deployed.

gusty girder
#

where can i get free cool looking templates for flask

rustic pebble
#

@vague vigil why dont u run it on docker then?

gusty girder
#

where can i get free cool looking templates for flask
??

rustic pebble
#

lol?

zealous siren
#

Penguin, as Azure SRE for my work, something is rotten, Azure should not be that bad

proven orchid
#

Hey guys, I just starting learning django few days ago. learned about models, views, templates. i also create a todoapp with create,update,delete functionality . But i am stuck now looking for what to learn next

#

any advice

vague vigil
#

@rustic pebble because they want non-technical people to have access to it at a specific URL. Otherwise I'd just tell them to pull the docker container and run it.

#

It is deployed in a docker container though

rustic pebble
#

here is docker's quo "this program doesn't run on my computer" "hmmm it runs on mine though" thus docker got created

vague vigil
#

@zealous siren do you know where common network issues might occur? The current URL is public, so no firewall issues that I know of. It's an app service app with a Production 1v2 plan, though I tried Production 2 and it made no difference.

#

Just to double check on the same image for fair comparison, the same thing that takes 21 seconds on azure is 2.8 seconds locally, using the same container.

zealous siren
#

penguin, do additional requests go faster?

#

the first one is obviously getting warmed up

vague vigil
#

No, they don't. And I currently have it set to always on, so theoretically there shouldn't be a warmup

zealous siren
#

weird

#

and it's a container?

vague vigil
#

Yup

#

Hosted on our azure container service

zealous siren
#

we have .Net Containers that do 30MS response time

vague vigil
#

I think I'll try deploying it on google cloud, see if I experience the same issues, and then go from there. If I'm having the same problems it's safe to assume it's something wrong with what I'm doing, otherwise I'll start messing with Azure.

zealous siren
#

yea, you can install Application Insights for Python

vague vigil
#

Awesome, I'll give that a look!
Thanks for the help yall.

thick cove
#
  File "C:\Users\Andre\Anaconda3\envs\Django Development\lib\site-packages\allauth\account\models.py", line 13, in <module>
    from .adapter import get_adapter
  File "C:\Users\Andre\Anaconda3\envs\Django Development\lib\site-packages\allauth\account\adapter.py", line 31, in <module>
    from ..utils import (
  File "C:\Users\Andre\Anaconda3\envs\Django Development\lib\site-packages\allauth\utils.py", line 12, in <module>
    from django.contrib.sites.models import Site
  File "C:\Users\Andre\Anaconda3\envs\Django Development\lib\site-packages\django\contrib\sites\models.py", line 78, in <module>
    class Site(models.Model):
  File "C:\Users\Andre\Anaconda3\envs\Django Development\lib\site-packages\django\db\models\base.py", line 115, in __new__
    "INSTALLED_APPS." % (module, name)
RuntimeError: Model class django.contrib.sites.models.Site doesn't declare an explicit app_label and isn't in an application in INSTALLED_APPS.

Hey, I'm trying to make a discord login for my Django website, following the allauth introduction and I get this.

rustic pebble
#

Discord login uses the OAuth2 schema

gusty girder
#

flask is for backend web development right

rustic pebble
#

It needs different implementation

#

flask is for backend web development rigth
@gusty girder Yes

gusty girder
#

then how do i customize the front end ui

#

to make it look cool

thick cove
#

allauth supports discord login, but that error doesent look OAuth or allauth related

rustic pebble
#

@gusty girder by writing the frontend

gusty girder
#

but then that requires html knowledge right

rustic pebble
#

@thick cove I am not really proficient on django sorry

#

but then that requires html knowledge right
@gusty girder Yes, javascript as well

lapis charm
#

if you are writing basic pages you will most likely use basic html css and js

gusty girder
#

isnt there a way to customize it without html css and js

thick cove
#

just add bootstrap πŸ‘

gusty girder
#

bootstrap?

thick cove
#

yes.

gusty girder
#

whats that?

rustic pebble
#

isnt there a way to customize it without html css and js
@gusty girder there isn't a way to do this no

#

You will need to use at minimum html and css for it

lapis charm
#

that is good idea to start without knowing much of how css work

rustic pebble
#

Bootstrap is a CSS module

gusty girder
#

ok ill check on bootstrap

zealous siren
#

it will look like bootstrap

gusty girder
#

so ill be able to customize the front end part with that

rustic pebble
#

Yes

zealous siren
#

to do front end, you need HTML/CSS/JS

lapis charm
#

you write basic html then add bootstrap to make it better without writing your own css

gusty girder
#

oh ok

#

are there any tutorials?

zealous siren
#

to make modern looking SPA you see today, JS is required

gusty girder
#

what about templates?

rustic pebble
#

to make modern looking SPA you see today, JS is required
@zealous siren You dont need to make a SPA in order to look modern lol

cold anchor
gusty girder
#

ok

#

what about templates?
the ones you get online

lapis charm
#

since you dont have a basic idea of html css start with that first worry about the rest later

gusty girder
#

okay

#

is html easily to learn?

zealous siren
#

Kiwi, when you make those really "slow" post calls, lack of JS will reveal itself πŸ˜›

gusty girder
#

or is it like django with the complex stuff?

lapis charm
#

what are you referring to ?

rustic pebble
#

@zealous siren simple fetchapi does the trick for most things except live updates

zealous siren
#

Sure and if you don't need it, that's fine

#

but modern type stuff you see from Google/Facebook will totally require you to know JS

gusty girder
#

what are you referring to ?
is html complex or is it easy to learn

rustic pebble
#

They are based on modern frameworks

gusty girder
#

but modern type stuff you see from Google/Facebook will totally require you to know JS
oh

rustic pebble
#

So yes you need state managers, sockets, clusters

zealous siren
#

like G Mail is JS hell

rustic pebble
#

Gmail is probably socket based

zealous siren
#

some of it is, yess

lapis charm
#

html is very is to learn it is not even a programming language

zealous siren
#

but JS powers those websockets

#

for front end

gusty girder
#

oh ok

rustic pebble
#

Yes, javascript does power them

#

But then again it isn't pure javascript

gusty girder
#

so ill learn css,javascript and html after getting used to flask and java

zealous siren
#

python and Java? going crazy there

lapis charm
#

you would not need much java if youre trying to get into web

gusty girder
#

is django backend too?

zealous siren
#

there is a ton of web powered by java

quick cargo
#

yes

lapis charm
#

jsp still exists?

zealous siren
#

no

#

but java powers a ton of backends

quick cargo
#

mhmm

zealous siren
#

JSP might exist, no one outside really old enterprise to hell uses it anymore