#web-development

2 messages · Page 156 of 1

opaque rivet
#

Yeah you can save channel information in a database.

hot crest
#

@opaque rivet and imagine user posted a new question which goes through channels
and then saved in database,
if he wanted to update the question then how can I do that in real-time too?

maybe refresh_from_db and sends back the data through socket again?

inland oak
#

So glad that it worked with flex boxes.
Tbh, I have zero experience in front end, and I saw this task as most difficult one in entire project 😉
It worked out quite well.

opaque rivet
lament glade
#

Right, something like that. Basically for example: posts=[{"title":"something"}, {"title":"something else"}] and the post.html is a template that looks like <div> <p>{{ title }}</p></div>

inland oak
#

I love interactive tutorials

#

Text Quest

#

THE FUN HAS BEEN DOUBLED!

#

I have my favourite game, where a lot of text quests. The game of my childhood.

opaque rivet
nimble epoch
lament glade
nimble epoch
#

imagine you have 1000000 items

#

no diff

lament glade
nimble epoch
#

that actually how you can access your data

hot crest
lament glade
nimble epoch
#

cause you have something like ```
posts = [
'item1': {
'name': 'Item 1',
'number': 10
}
]

opaque rivet
nimble epoch
#

of course you probably wanna use databases for big data not objects

lament glade
#

Thank you

nimble epoch
#

yaw

opaque rivet
#

fair enough, then go for it

hot crest
#

thanks man

hot crest
opaque rivet
#

by the way, if I want to setup ci/cd (github actions), will I have to run docker setup scripts?

inland oak
calm plume
#

It's completely static for me. Can't even go to another page.

inland oak
#
name: Django CI

on: [push, pull_request]

jobs:
  main-workflow:
    runs-on: ubuntu-latest
    strategy:
      max-parallel: 4
      matrix:
        python-version: [3.8, 3.9]

    steps:
    - uses: actions/checkout@v2
    - name: Set up Python ${{ matrix.python-version }}
      uses: actions/setup-python@v2
      with:
        python-version: ${{ matrix.python-version }}
    - name: Install Dependencies
      run: |
        python -m pip install --upgrade pip
        pip install -r requirements.txt
    - name: Analysing the code with pylint
      run: |
        python scripts.py test pylint
    - name: Analysing the code with flake8
      run: |
        python scripts.py test flake
    - name: Running Unit Tests
      run: |
        python scripts.py test unit -c -p
    - name: Sphinx build
      run: |
        python scripts.py sphinx build
#

my django github script

#

you can probably try to write scripts which builds docker (to check that docker can be built)

#

if you wish

hot crest
calm plume
#

Then how do you have so many users?

#

If the site only has a UI

nimble epoch
#

wtf was that?

calm plume
#

@dusk portal So what exactly are you trying to do?

dusk portal
#

So firstly hello
I use flask
I made different websites and stuff for ppls

#

I face issue at rendering images,text font and things (console errors)

#

When i use bootstrap

#

And when i use tailwind css i just copy cdn
Then go to tailblocks site then copy paste

calm plume
#

Okay

dusk portal
#

Nope
I code at flask lol

calm plume
#

Ignore the node thing

dusk portal
#

Ok

calm plume
#

So what's not working with bootstrap?

dusk portal
#

Ig bootstrap don't have cdn

#

Is it true?

calm plume
#

It does

dusk portal
#

It affect the code?

calm plume
#
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.1/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-+0n0xVW2eSR5OomGNYDnhzAbDsOXxcvSN1TPprVMTNDbiYZCxYbOOl7+AMvyTG2x" crossorigin="anonymous">
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.1/dist/js/bootstrap.bundle.min.js" integrity="sha384-gtEjrD/SeCtmISkJkNUaaKMoLD0//ElJ19smozuHV6z3Iehds+3Ulb9Bn9Plx0x4" crossorigin="anonymous"></script>``` is the bootstrap cdn
dusk portal
#

Ok i remember lol yes

calm plume
#

But that's not the best way

#

But it's probably the best for you actually

dusk portal
#

Ok the error which i face by Bootstrap is

#

I copy the cdn stuff and things
In that no issues

#

But when i copy code and paste

#

And run on my browser

#

I can't load images

#

The font is not loaded.

#

In short some static files ,images,js,vendor things error

calm plume
#

Can you show the code in a pastebin?

#

!paste

lavish prismBOT
#

Pasting large amounts of code

If your code is too long to fit in a codeblock in discord, you can paste your code here:
https://paste.pydis.com/

After pasting your code, save it by clicking the floppy disk icon in the top right, or by typing ctrl + S. After doing that, the URL should change. Copy the URL and post it here so others can see it.

calm plume
#

The html code

dusk portal
#

I don't have code rn but u face that issue @calm plume

#

Can u suggest me ur exp and tips to avoid that errors

#

It's 11 pm

#

I'm on my bed at phone

calm plume
#

I don't use Bootstrap, I usually use raw Tailwind and normal CSS

dusk portal
calm plume
#

But I know how to use html, so I can spot basic issues if I see the code

calm plume
dusk portal
#

U write whole front-end by urself

#

😱

#

@calm plume did u?

calm plume
#

I'm working on one, although it isn't finished

dusk portal
calm plume
#

I don't use tailwindcss cdn, because that's slow

#

I use the tailwindcss npm package

dusk portal
#

Firstly idk what is cdn

#

I'm noob at front-end

dusk portal
#

When i open site

#

It's on top

#

👀

calm plume
#

Yes, the npm package is the best way to use tailwind

dusk portal
#

Oh

#

How to use

#

Idk

#

Idk that much

calm plume
#

You don't need too

dusk portal
#

What should i do ;_;

calm plume
#

Unless you're making a complex frontend, the cdn should be enough

#

So, do you want to use Bootstrap or Tailwind?

#

You should choose one

magic sluice
#

not sure if it is relevant but if you want you can try my lib to write web front end

#

it should do for you the bootstrap and css

dusk portal
calm plume
#

If you're using Bootstrap, then you can't use Tailwind. Are you okay with that?

dusk portal
#

U plz suggest me

#

What should i use

#

😭

calm plume
#

If you don't want to write any type of CSS, use bootstrap

magic sluice
#

if you do not want to spend to much time on the ui

dusk portal
#

What's next step

calm plume
#

Do you have your code?

#

It'll be really hard to do it without

#

But if you follow the docs, it should be easy

dusk portal
#

I have seen a 2hr tut. To use bootstrap

dusk portal
calm plume
#

You don't need to read all the docs

#

Just the installation ones

dusk portal
#

Ok

#

Add friend

#

I hope u will help

#

Cua

#

Cya going to sleep

#

Good night

opaque rivet
#

btw, you can use bootstrap and tailwindcss, just import from cdn

calm plume
#

You can.

#

But it's better to choose one

#

Especially if you're new to frontend

pure thistle
#

Anyone know how to solve relative import beyond top-level package like I am importing another model from other app to use it as foreign key in Django

wooden ruin
calm plume
#

Tailwind is a series of utility classes, it isn't a component library (so it has things like w-1 for width: 0.25rem;). Bootstrap and Bulma are component libraries, which means they have prebuilt components for you to use

wooden ruin
#

by components you mean things like carousels, media cards, spinners etc?

calm plume
#

Yeah, and buttons and tabbers and the such

wooden ruin
#

ohhhh ok

native tide
calm plume
#

Imo, yes, but some people don't like doing that

native tide
#

Then that's not being a real web dev

#

If u just want to copy paste everything

#

Css is ez man

#

Its ez to use

indigo kettle
#

That's a pretty elitist view of web dev

#

there are many parts to web development, sometimes you just want the frontend to be simple and not have to think about the css

calm plume
native tide
calm plume
#

Some people don't want to waste time on css

#

So they use components

#

Which is their way of doing things

#

No need to judge them for using tools available to them

native tide
calm plume
#

Yes

#

Which is something that not everyone needs

#

Some people are fine with basic websites with bootstrap

native tide
native tide
indigo kettle
#

it sounded like you were saying that using bootstrap is bad

native tide
#

And it sounded wrong

#

Even i am not good and i don't judge i only know html and css , i need to learn js too

indigo kettle
#

gotcha

opaque rivet
#

if you wanna try tailwindUI out I can send you over my account

calm plume
#

TailwindUI's free components are amazing too

opaque rivet
trail jungle
#

Hi friends,

I would like to know if I can ask a question regarding how to put a web app designed with Flask into production. Is it pertinent to do it through this channel?

native tide
calm plume
trail jungle
shadow nova
#

i want to edit post in a blog app , so i used the model forms which i used to add a new post , now i want to display the previous data in forms while editing

#

but i'm getting empty form

#

anyone ??

candid ridge
#

For beginners, which is more recommended django or flask?

calm plume
#

Flask is probably easier to learn since it's a micro framework, but they do different things

candid ridge
#

On*

calm plume
#

Flask is more oriented toward API creation, while Django is a batteries included framework for writing the whole backend of a website, including a database and more

candid ridge
#

So wouldn’t it be better to learn django? Especially if I want to get into the software engineering world?

calm plume
#

Django is better imo, yes

#

And it's used in production by a number of huge companies

#

For example, Django powers Instagram

candid ridge
#

Nice. Any valuable tutorials you can point me to?

calm plume
#

The official Django tutorial is really good. And if you prefer videos, Corey Schafer has a good series on it

trail jungle
#

this is my project structure, and i have the wsgi.py file with the app object with app run. The project use blueprint for modular solution, and each controller file build the respective blueprint. Each blueprint is imported in wsgi... then i have circular referenciation. Each controller import db and app from wsgi.py

#

is very confused, run in dev environment but not in EC2 ubuntu 18.04 using docker 😦

frail cairn
#

line 2, in <module>
from flask_sqlalchemy import SQLAlchemy
ModuleNotFoundError: No module named 'flask_sqlalchemy'

#

and if u ask yea i download Flask-SQLAlchemy like this

opaque rivet
#

@frail cairn run pip list too see installed packages

frail cairn
native tide
#

hello world

kindred zinc
#

@frail cairn you using a virtual environment? Maybe the package is installed on your personal machine and you need it in the virtual one

native tide
#

ok i’m learning how to do this

native tide
valid girder
#

Hi folks - I am excited to share a free and super-easy-to-use “Django code generator” web tool that I have been building : https://www.imagine.ai

Using the web UI, you can easily bootstrap your Django app (complete setup for unit tests, lint, docker, etc) as well as generate clean, high quality code for your ORM/models and API (REST/GraphQL).

PS - the tool is free and no sign up is needed 🙂

Also, this is still in beta, so would love to hear any feedback, suggestions and improvements!! Also, if you run into any issues, please DM me - am here to fix them! 🙂

Generate dockerized, production-ready, fully test-covered code for your backend project starter, ORMs and CRUD APIs

inland oak
#

bump

wooden ruin
# valid girder Hi folks - I am excited to share a free and super-easy-to-use “Django code gener...

that looks awesome! direct support for containerization, easy to follow UI for making models, and API endpoints straight out of the box. if you'd like, i'd challenge you to implement support for ASGI server support in order to support things like Channels and Daphne for deployment. I also love how you directly incorperate best practices into code with READMEs and easy support for testing. I would also suggest allowing the option for token authentication (this can be implemented using a library like drf-simplejwt for example) if a user wishes to run this server as a backend API and have an independent React/Vue frontend running, it can be a pain to configure authentication/requests. However, i'm a big fan of how you approached this, by minimizing having to write the same code over and over again and using best practices. Well done! Definitely adding this to my bookmarks tab 😄

inland oak
inland oak
grave needle
#

How do we configure a url with Django 3.2?

grave needle
#

Anyway, so back to where i was, how do i configure a url?

inland oak
# grave needle Anyway, so back to where i was, how do i configure a url?

as most dummy way

root folder has links to groups of urls for different apps

project_settings_folder/urls.py

from django.urls import include, path

urlpatterns = [
    path('', include('main.urls')),
    path('commodity/', include('commodity.urls')),

app has your specific links

commodity/urls.py

from django.urls import path
from . import views

# API endpoints
urlpatterns = format_suffix_patterns([
    path('list', views.ViewList.as_view(), name='ship-get'),
    path('get_main', views.index, name='index')
])

some request

views.py

def index(request):
    data = Ship.objects.all()
    template = loader.get_template('get_main.html')
    context = {'data': data, 'fields': list(ShipAdmin.list_display)}
    return HttpResponse(template.render(context, request))
valid girder
# wooden ruin that looks awesome! direct support for containerization, easy to follow UI for m...

Thanks! Thats super kind of you.

  • Authentication and authorization is on our roadmap, coming soon. Will allow providers like auth0, google, fb, github etc. So single click codegen for those integrations.
  • React frontend side of the API calling code also coming.

Honestly your feedback means a lot. This has come together many sleepless nights later 🙂 The great joy is in having people who use it....if you could share with anyone who you think it would be helpful, that would be amazing 🙂
And let me know what other features would you like!

valid girder
# inland oak pytest ;b

We generate code for tests (100% coverage comes with the codegen). But yeah will add support for choosing the test library/framework including pytest

inland oak
#

considering pytest complete support of unittest tests, it is probably not that important may be

#

but its tests just look better, and comfortabler to handle

valid girder
#

yeah but def given its popularity, will add pytest.

#

Do you guys structure your projects as a single django app or multiple?

inland oak
#

multiple django apps

#

one app per one section that has meaning in separation for its model object

#

define app better though, do you mean app as internal django app? or as separated django project?

valid girder
#

yeah I meant internal django app

inland oak
#

answer remains the same then

valid girder
#

as in if its a microservice env, do you make each service as a single django app?

#

and I'm guessing you keep separate models, database per app so complete separation of concerns with just API traffic between them?

#

We're thinking how to add support for multiple apps....

inland oak
#

apps remain connected with foreign keys

valid girder
#

Got it. So we could allow you to "move" a data model to a specific app, still allow some cross-app access. And make APIs etc completely separate. And then you can choose whether you want these apps within a single django project or generate separate django service with 1 app each (so a more microservice setup)...

#

what would you want for deployment if we could offer anything as part of this

valid girder
#

re: k8s, would you want terraform/ansible scripts?

sage pewter
valid girder
#

So just generate terraform scripts?

#

or you'd prefer k8s yml...

sage pewter
# valid girder So just generate terraform scripts?

I have one question though. As a developer, I still have not found myself comfortable using no-code tools. This seems like GUI based scaffold, almost no-code and I am tempted to try. What has been your motivation to develop this tool?

sage pewter
#

same types of tools that developers at Google and Facebook use
Do you know from experience if these kind of tools are popular at these companies?

#

I worked at Twitter from 2012 to 2015. This was when Ruby of Rails was going out, and Microservices based architecture with Scala was becoming popular. We tried to develop such scaffold tools, but ultimately what succeeded then was an example wizard with step-by-step high level demo and pointer.

inland oak
#

all right. What would be the most easiest to learn quickly tool from zero for the task

I have multiple VPSes, with SSH accesses
I need to deploy to all of them, the same docker container but with 4 different environment keys to each of them?

#

preferably wishing to receive monitoring update of their alive status

valid girder
# sage pewter I have one question though. As a developer, I still have not found myself comfo...

its a great question - as someone who’s been a developer for many years, my first and foremost motivation in building this was two-fold:

  • I really, really, really don’t like repetitiveness and inconsistencies in code-writing (that way I’m a lazy programmer ;))
  • Also, like you, I really don’t believe in traditional no-code / low-code, where people some how believe you don’t need code at all. While this might be true for simple landing pages, and very basic frontend based apps, it falls apart the moment you need to write custom code. Also nothing beats native integration vs API based integration with no-code solutions

My goal with imagine was to bring the simplicity of no-code to writing the basic building blocks of an app, so that engineers could get high quality code, best practice code which they can then add custom business logic to.

Over time, I want to expand the set of basic features / boilerplate code one can generate (e.g. auth, notifications, payments, etc)

valid girder
sage pewter
sage pewter
#

I am extremely tempted to try your tool. I am thinking of what to build 🙂

valid girder
# sage pewter At twitter, it was go/service - but a wizard. We started as 3-member team, but g...

Another great question 🙂 At the moment I’m taking an engineer-first approach and most excited by building something that engineers love. As a business use case one thing I’ve considered is allowing businesses to create/modify their own templates which they can use to get consistency.
Because while big companies can afford to spend money to build such things, other companies are not able to afford to do it but still they value consistency.
Thats one idea that has come up as I’ve talked to friends in companies and other entrepreneurs…but for now I’m excited to build for the developer community, that feels so much more fun than building for enterprises…

valid girder
sage pewter
inland oak
#

me three, until I learned all features at least. It sort of acts like interactive tutorial.

native tide
#

WHAT LANGUAGES DO YOU USE FOR WEB DEVELOPEMENT

dusk portal
#
  • for frontend i copy from bootstrap and jinja2/jinja templating
native tide
#

cuz i dont use boostrap

dusk portal
#

u use frontend from??

#

u write whole html?

#

@native tide

native tide
#

whole html

dusk portal
#

lo,

native tide
dusk portal
native tide
#

i need to leanr js

dusk portal
#

same

#

btw as u dont know js

#

so ig u wont be able to make nice webpages

#

ig

native tide
#

until i dont know js i cant make a complete working website

dusk portal
#

u know what is bootstrap and tailwind(tailblocks)

native tide
#

yes

#

but i dont use them

dusk portal
#

i dont want to waste time on

#

learning html css js

#

u should only know things like div form action method

#

and stuff which help in backend

#

and jinja templating

#

just copy code from bootstrap or tailwind with cdn and edit (as u know basics)

#

if u really want to learn frontend learnn things like react,angular,etc. one page application things

#

@native tide

dusk portal
# native tide but i dont use them

use them they have thousands of templates with code just read the docs , so u know how to implement them or see lectures as bootstrap is very big site and it has own rules , if u learn it nicely u dont need to learn html css ,jinja and some basics of html css is enough for frontend

native tide
#

?

dusk portal
#

it contains js in the code

minor pumice
#

Hey guys I am looking to learn websockets with django and react can anyone suggest good resources!!!

native tide
minor pumice
#

If anyone else knows do recommend

dusk portal
nimble epoch
nimble epoch
#

and for websocket go to readthedocs

minor pumice
#

I am trying with the official documentation

#

But is there any good video tutorial?

dusk portal
nimble epoch
#

if you are interested in reading or at least you are comfortable with it that main docs you going now for is good. they are better than videos

dusk portal
#

😢

nimble epoch
#

i exactly used to be like you. just give it a try

dusk portal
#

i dont know to get knowledge from docs

#

mean

#

take example flask

#

i start reading

#

how can i know topics

#

mean all topic overview

#

as videos are in playlist so we know content in playlist

#

but in docs idk how to take more output from docs

nimble epoch
#

usually the topics are on top of page or title or subtitles

dusk portal
#

yes

#

idk the way to get knowledge

#

frrom docs

nimble epoch
#

no idea but videos are only for beginners in my idea you can get more detail with docs

chrome trench
#

I want to host a very simple github page that takes input from a python web scraper scrip (resulting in a list of 20 iframes) that updates on a daily basis. Is it possible to get this working with Github Pages and Actions? Thanks in advance!

nimble epoch
#

you want your data be updated everyday and be shown in your website, right?

#

based on the scraped data

chrome trench
#

Exactly! I want the script to run and the new iframes to be deployed to the Github Page

nimble epoch
#

so i think you need a cloud platform cause github pages are for statics only i think

chrome trench
#

I see. Can you use something like Azure Functions to run the scraper and trigger a deploy or should I go for something like a Flask server?

nimble epoch
#

havent ever tried Azure Function but you can also do that with flask or ...

#

you know im not sure about this one so better wait until someone will give you more details

chrome trench
#

Will do, anyways thanks for taking the time out to discuss it. Have a great day!

nimble epoch
#

you use scrapy or selenium right?

chrome trench
#

Ive used Beatuiful Soup. It generates a list of 20 iframes at the end of the line.

nimble epoch
#

oh

#

so you can probably use flask to grab data

#

or even json output like scrapy

chrome trench
#

Will def look into it once I get the website up and running!

nimble epoch
#

def? view function?

elfin junco
#

Hey guys need some advice what is the best way to create a Whatsapp bot it just needs to ask certain multiple choice questions to the user and based on that present a link and contact number .

inland oak
#

hmm.... it would be easier to do with gitlab pages
but it can be done with github pages too... but you need to find out how to deploy
github pages with artifacts usage for that

#

although more easier would be

#

having just your own microservice

#

having infinity loop task

#

that gives results in html form to your static folder

#

which would be hosted at the same place where your application is

#

it requires some hosting place though, and github actions + pages require no hosting

#

I can give you example how to do the same with gitlab pages

chrome trench
#

@inland oak Thanks for the response! Happy to use Gitlab pages as well

inland oak
#

.gitlab-ci.yml

image: python:latest

before_script:
  - python -V  # Print out python version for debugging
  - pip install -r requirements.txt

# if your want linting
flake:
  script:
    - python scripts.py test flake

# if you want unit tests
unit:
  script:
    - python scripts.py test unit

pages:
  script:
    - python scripts.py test unit -r
    - python scripts.py sphinx build
    - mv docs/build public/
  artifacts:
    paths:
      - public
  rules:
    - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
#

essentially this.

#

in before_script make installation

#

in script, run your thing

#

and gathered html results, move to folder public

#

they would be automatically hosted

chrome trench
#

Wow, thanks! Reading up on Gitlab pages and the ymlfile you posted. Really appreciate your input @inland oak

dusk portal
#

hey? anyone here ??

#

i want a small help + suggestion

solemn glacier
#

whats up

dusk portal
#

u know flask??

solemn glacier
#

a little bit

dusk portal
#

ok try

#

u know how to make login page??

solemn glacier
#

yes

dusk portal
#

mean backend

solemn glacier
#

yes

dusk portal
#

so u know session ?

solemn glacier
#

yes, its been a while since i've worked with flask session / auth stuff but shoot

dusk portal
#

ok

#

so i have created 1 login panel

#

i wanted to create 1 more login panel now

#

but have few doubts

#

so r u free

#

can u answer?

solemn glacier
#

what is the question my friend

dusk portal
#
@app.route("/login",methods=["GET","POST"])
def login():
    if 'uname' in session and session['uname']==params['admin-user']:
        return render_template('dashboard.html',params=params)
    if request.method=="POST":
        username=request.form.get('username')
        password=request.form.get('password')
        if username==params['admin-user'] and password==params['admin-pass']:
            session['uname']=username
            return render_template('dashboard.html',params=params)
        else:
            return render_template('login.html')
        return render_template('login.html')
    return render_template('login.html')```
#

its 1st login panel

#

so when i want to create 2nd

#

how can i create 2nd

solemn glacier
#

what is the purpose of the second?

#

a second login panel

dusk portal
#

i have another button and i wanted that 1st cant enter

#

thats why

#

so can i do it with flask??

#

i mean is it possible with flask

solemn glacier
#

I dont inderstand what you're looking for. Your have a login page and back end, what is it exactly that you want to do? you've said you want to create a second login page but could you be more clear

dusk portal
#

can i stream it??

solemn glacier
#

You want to have multiple levels of authentication?

dusk portal
solemn glacier
#

as In log in once, and once you're logged in be able to access a nother login for to another section of the site?

dusk portal
#

u have 1 page which have 2 buttons , TASK VIEWER and second TASK HANDLER so i have made login for 1st

#

i want to make login for 2nd

solemn glacier
#

when you say 1st and 2nd awhat are you referring to

#

you only need one login page for your website

dusk portal
#

1st = Task viewer

solemn glacier
#

they are both on the same page

dusk portal
solemn glacier
#

send the function name and decorators for your views / route for the 1 page with 2 button

dusk portal
#

ok

solemn glacier
#

is it dashboard.html?

dusk portal
#

wait let me give

#

2 mins pl

#

z

solemn glacier
#

i would say don't render_template() on successful login, use redirect(url_for(DASHOBOARD_FUNCTION_NAME)

#

redirect(url_for('DASHOBOARD_FUNCTION_NAME') put function name in single quotes

#

and apply your session to the dashboard route

dusk portal
#
@app.route("/login",methods=["GET","POST"])
def login():
    if 'uname' in session and session ['uname']==params['admin-user1']:
        return render_template('taskcreator.html',params=params)
    if (request.method=="POST"):
        username=request.form.get('username')
        password=request.form.get('password')
        if username==params['admin-user1'] and password==params['admin-pass1']:
            session['uname']=username
            return render_template('taskcreator.html',params=params)
        else:
            return render_template('login.html')
        return render_template('login.html')
    return render_template('login.html')```
#

this is login 1 which is for taskcreator.html

#

and working properly

solemn glacier
#

do you have a @app.route("/taskcreator")

dusk portal
#

@app.route("/login1",methods=["GET","POST"])
def login1():
    if 'uname1' in session and session ['uname1']==params['admin-user2']:
        return render_template('taskhandler.html',params=params)
    if (request.method=="POST"):
        username=request.form.get('username')
        password=request.form.get('password')
        if username==params['admin-user2'] and password==params['admin-pass2']:
            session['uname1']=username
            return render_template('taskhandler.html',params=params)
        else:
            return render_template('login.html')
        return render_template('login.html')
    return render_template('login.html')```
inland oak
dusk portal
#

login and taskcreator are working

#

login1

dusk portal
solemn glacier
#

login1 is rendering the page after

#

do you have an endpoint for the taskhandler

terse vapor
#

wait

dusk portal
terse vapor
#

ur using login.html for two login route?

dusk portal
#

yes

#

u got it

#

yes

terse vapor
#

ok

#

what seems to be the error?

dusk portal
#

and i know why also

#

but asking

#

u know this

terse vapor
#

ok

dusk portal
#

app.config['SECRET_KEY'] = "secret_string"

#

i have 2 session

#

but key is only 1

solemn glacier
#

how do i paste code

#

[code]test[/code]

#

@app.route("/taskcreator",methods=["GET","POST"])
def show_taskcreator():
if 'uname1' in session and session ['uname1']==params['admin-user2']:
return render_template('taskhandler.html',params=params)
else:
"no access"

@app.route("/login1",methods=["GET","POST"])
def login1():
if 'uname1' in session and session ['uname1']==params['admin-user2']:
return redirect(url_for('taskhandler.html',params=params)) # note i dont know how you can handle jinja template rendering here, maybe another way
if (request.method=="POST"):
username=request.form.get('username')
password=request.form.get('password')
if username==params['admin-user2'] and password==params['admin-pass2']:
session['uname1']=username
return redirect(url_for('taskhandler.html',params=params))
else:
return render_template('login.html')
return render_template('login.html')
return render_template('login.html')

#

import redirect,url_for from flask

#

let me fix the parameter issue as well

dusk portal
#

no error bro

#

listen full issue first

#

;-;

#

so when im logged in with 1st panel it do not ask for idp when i click to login in 2nd panel

#

but when i dont login with 1st panel it ask for pass in 2nd

#

so problem is in

#
    if 'uname1' in session and session ['uname1']==params['admin-user2']:
        return render_template('taskhandler.html',params=params)```
#

thats what im asking

#

should i create 2nd session key

#

ok done that now

#

but is thispy session['uname1']=username

solemn glacier
#

im having trouble because i stilldont fuly understand your problem, what is the 2nd panel and whats it for

dusk portal
#

it asks for password and if correct it should render taskhandler

#

and first is correct

#

ignore it

solemn glacier
#

so login 1 access task creator, login 2 access task creator and task handler?

#

is that the goal

dusk portal
#

login = taskcreator and login 1= task handler

#

login and taskcreator works properly ignore

solemn glacier
#

they are two seperate pages ? task crator and task handler?

#

ok

solemn glacier
#

so you want to create a second

#

log in page, that redirect to the task handler

#

not the task cretor

#

but it doesnt work

dusk portal
#

ok listen

opaque rivet
#

what's the difference between the Dockerfile and docker-compose? I know that Dockerfile creates the image

native tide
dusk portal
#

😂😂

native tide
#

yeh

#

lol

native tide
#

same naam hai hamara

dusk portal
#

@native tide hi aryan
Talk here in English
I'm dm hindi

native tide
#

k

calm plume
native tide
#

ValueError at /profile/
ModelForm has no model class specified.

#

from django.shortcuts import render, redirect
from django.contrib import messages
from django.contrib.auth.decorators import login_required
from .forms import UserRegisterForm, UserUpdateForm, ProfileUpdateForm

def register(request):
if request.method == 'POST':
form = UserRegisterForm(request.POST)
if form.is_valid():
form.save()
username = form.cleaned_data.get("username")
messages.success(request, f'Yor account has been created! You are now able to login')
return redirect('/login')
else:
form = UserRegisterForm()
return render(request, 'users/register.html',{'form': form})

@login_required
def profile(request):
u_form = UserUpdateForm()
p_form = ProfileUpdateForm()

context = {
    'u_form' : u_form,
    'p_form' : p_form 
}
return render(request,'users/profile.html', context)
#

from django import forms
from django.contrib.auth.models import User
from django.contrib.auth.forms import UserCreationForm
from .models import Profile
class UserRegisterForm(UserCreationForm):
email = forms.EmailField()
class Meta:
model = User
fields = ['username', 'email','password1','password2']

class UserUpdateForm(forms.ModelForm):
models = User
fields = ['username','email']

class ProfileUpdateForm(forms.ModelForm):
class Meta:
models = Profile
fields = ['image']

#

help me solve this bug

coarse haven
#

!code

lavish prismBOT
#

Here's how to format Python code on Discord:

```py
print('Hello world!')
```

These are backticks, not quotes. Check this out if you can't find the backtick key.

opaque rivet
#

@calm plume thanks - so Dockerfile and docker compose are interchangeable?

calm plume
#

I don't think so

#

I think you need a Dockerfile if you have a compose

#

Lemme check the compose docs

#

Using Compose is basically a three-step process:

  1. Define your app’s environment with a Dockerfile so it can be reproduced anywhere.
  2. Define the services that make up your app in docker-compose.yml so they can be run together in an isolated environment.
  3. Run docker compose up and the Docker compose command starts and runs your entire app. You can alternatively run docker-compose up using the docker-compose binary.
#

So you need both a Dockerfile and a compose config

native tide
#

I've got url rules setup in main.py for each route in another module.
How can I use flask cache decorators in test.py?

Cheers

main.py

from flask import Flask
from test import Test

app = Flask('app')
cache = Cache(app,config={'CACHE_TYPE': 'simple'})

app.add_url_rule('/route1', view_func=Sheet.test_route1, methods=['GET'])
app.add_url_rule('/route2', view_func=Sheet.test_route2, methods=['GET'])

if __name__ == '__main__':
    app.run('localhost', '5000', debug=True)

test.py

class Test:
    @staticmethod
    def test_route1():
        return 'Hello world 1'
    @staticmethod
    def test_route2():
        return 'Hello world 2'
opaque rivet
calm plume
#

That sounds about right

solid goblet
#

so talking to ionos

#

they said "website builder has no capability of doing subscription payment systems"

unless i can find discord html code

dusk portal
calm plume
#

You'll need to make the html/css yourself if you want payment systems

calm plume
#

Unless you hire someone to do it for you

calm plume
solid goblet
#

where can i find discord html code?

#

if possible

calm plume
#

You can't find the full thing

#

And even if you could, it would't be enough

solid goblet
#

also didnt people in here tell me to use ionos because they had a backend

dusk portal
#

yes u should know basic html css

calm plume
#

You would need css and js to make it look good

calm plume
solid goblet
#

lmao

#

well i just spent 250$ + 60$ a month so they could do this, because everyone kept telling me ionos COULD do it

lavish prismBOT
#

docker-compose.yml lines 27 to 32

redis:
  << : *logging
  << : *restart_policy
  image: redis:5.0.9
  ports:
    - "127.0.0.1:6379:6379"```
opaque rivet
calm plume
#

Good luck!

solid goblet
calm plume
#

The best you could find is inspect element, but that wouldn't work

#

Since you don't have the css classes

solid goblet
#

so not possible at all then?

calm plume
#

Correctly, no

#

Incorrectly, still no

#

Unless all you want is blank text

dusk portal
#

Oh

#

So u were telling about Bootstrap

#

@calm plume

solid goblet
#

?

dusk portal
#

Could do that here refers to

calm plume
calm plume
dusk portal
#

Yes u told i should choose bootstrap and i said ok

calm plume
#

You said you wanted to do bootstrap, yes

solid goblet
#

IONOS support is kind of confusing me

#

i dont know whether they want discord full html code

or the html code for a subscription payment system

dusk portal
solid goblet
#

all they said was "discord html code"

calm plume
#

Just read the installation docs

dusk portal
#

Oh

dense phoenix
#

How to make a custom URL with flask?

inland oak
dense phoenix
#

like

inland oak
#

ops, it is Django

#

Flask slightly different

#

Check mega tutorial then

#

it will eliminate a lot of questions regarding Flask

hollow bronze
#

hi.

#

guys

solemn glacier
#

hi

hollow bronze
#

@solemn glacier

#

are you an expert in python,right?

solemn glacier
#

what is your question related to

hollow bronze
#

i wanna develop my own website

solemn glacier
#

ok

hollow bronze
#

have you ever done before?

solemn glacier
#

i know a bit about it. are you planning on flask or django

hollow bronze
#

django

solemn glacier
#

maybe somebody else may be able to assist you better than i would be able to, i have more exp with flask

hollow bronze
#

then let's use it.

solemn glacier
#

you don't have a specific problem? or just questions related to what you plan on building

#

what is your concern

hollow bronze
#

i want hire you.

#

don't worry about money

native tide
#

@hollow bronze Hey, we do not allow for hiring here

hollow bronze
#

where i can hire someone?

nimble epoch
dusk portal
dusk portal
#

@hollow bronze hey bro do u have exp in python
If u don't have so don't start with django
Start with flask

acoustic yew
#

Will anybody help me how to start in django

#

Plz

nimble epoch
#

go to official website

violet briar
#

should I use celery or should I use threading for background tasks like sending emails?

opaque rivet
modern anchor
#

Front End

function Welcome() {
    return (
      <div className="Welcome">
        <h1>Welcome</h1>
        <a href="http://127.0.0.1:5000/login"><button>Signin with google</button></a>
      </div>
    );
  }
  
  export default Welcome;

Backend

@app.route('/authorize')
def authorize():
    google = oauth.create_client('google')
    token = google.authorize_access_token()
    resp = google.get('userinfo',token=token)
    resp.raise_for_status()
    user_info = resp.json()
    session["email"]= json.dumps(user_info)
    return redirect('http://localhost:3000/home')

Now im just redirecting back to the front end from backend but i have to make a session with this data on the front end how can i do it?

limber laurel
#

How can I change the working route in django-environ?

#

Im having this issue where it is searching for the .env file where I dont want it to be searching for it

cloud spade
#

I have a text file with key words. It looks lie this:

tomCruise Tom Cruise Los Angeles, CA http://www.tomcruise.com Official TomCruise.com crew tweets. We love you guys! Visit us at Facebook! ENDBIO katieH NicoleKidman END PerezHilton Perez Hilton Hollywood, California http://www.PerezH... Perez Hilton is the creator and writer of one of the most famous websites in the world. And he also loves music a lot! ENDBIO tomCruise katieH NicoleKidman END

I would like to build a dictionary from of the following format from the text file.

[ 'tomCruise':{ 'name': 'Tom Cruise', 'bio': 'Official TomCruise.com crew tweets. We love you guys!\nVisit us at Facebook!', 'location': 'Los Angeles, CA', 'web': 'http://www.tomcruise.com', 'following': ['katieH', 'NicoleKidman'], }, 'PerezHilton':{ 'name': 'Perez Hilton', 'bio': 'Perez Hilton is the creator and writer of one of the most famous websites in the world. And he also loves music - a lot!', 'location': 'Hollywood, California', 'web': 'http://www.PerezH...', 'following': ['tomCruise', 'katieH', 'NicoleKidman'], } ]

#

Any one do this code

opaque rivet
#

have you guys ever moved your django project into one singular directory? I tried to do so and I'm getting ModuleNotFound errors.

quick cargo
#

you cant do that

#

you have to follow the Django structure it generates for you really

opaque rivet
#

really? so manage.py always has to be in the root directory?

#

;/

#

I wanted to split my project folder into a backend and frontend directories so I can have docker files in both, then docker-compose.yml in the root

#

that's an easy hour or two down the drain

native tide
native tide
native tide
neon flax
terse vapor
#

I'm currently following the flask docs regarding flask-migrate, but when I tried the first script in the page, it appears error: alembic.util.exc.CommandError: SQLAlchemy 1.3.0 or greater is required.

solemn glacier
#

are you in the right virtual environment

wooden ruin
shy estuary
#

how do i perform raw SQL crud operations with flask WITHOUT sqlalchemy or any other ORM? Like directly connecting the database and executing the sql commands?

shy estuary
modern anchor
#

Python Flask```py
@app.route('/authorize')
def authorize():
google = oauth.create_client('google')
token = google.authorize_access_token()
resp = google.get('userinfo',token=token)
resp.raise_for_status()
user_info = resp.json()
email = user_info["email"]
id = user_info["id"]
access_token = create_access_token({
"id":id,
"email":email
})
return access_token

After Oauth i need to send this access token i made to my react frontend how can i do it
now i'm just returning access_token , i cant make get request to authorize route because its a route for oauth
native tide
#

Difference between port and ip address?

chilly falcon
#

hello guyz i was learning django for front end should i used front end framework or template based front end is good

#

??

chilly falcon
#

there are 4 type of ip address public private static dynamic

#

In computer networking, a port is a communication endpoint. At the software level, within an operating system, a port is a logical construct that identifies a specific process or a type of network service.

dusk portal
#

anyone here i need a help

nimble epoch
native tide
#

How would one pass paramters to a class within an external module in Flask routes?

I have the following which of course returns:
TypeError: route1() missing 1 required positional argument: 'self'

# main.py

from flask import Flask
from cache import cache

from module1 import Client

app = Flask('app')
cache.init_app(app)

app.add_url_rule('/route1', view_func=Client.route1, methods=['GET'])

if __name__ == '__main__':
    app.run('localhost', '5000', debug=True)


# module1.py

from cache import cache
from flask import request

class Client:
    def __init__(self):
        self.param1 = request.args.get('param1')
        self.param2 = request.args.get('param2')

    @staticmethod
    @Cache#7020.cached(timeout=60)
    def route1(self):
        return f'Route1, {self.param1},  {self.param2}'
dusk portal
#

@nimble epoch a small issue if u r free for a while

nimble epoch
#

what is it about?

#

django?

dusk portal
#

May i stream/share screen

#

Flask

nimble epoch
#

oh sorry bout that

dusk portal
#

U don't know flask?

nimble epoch
#

a little i dont remember well maybe something that are the same in every frameworks

dusk portal
#

Yes lol

opaque rivet
native tide
native tide
#

Oh!

#

Of course haha cheers!

opaque rivet
#

static-methods are methods which run on the class, instead of the class instance 👍

native tide
#

Need to create an instance of course

#

Awesome mate thanks so much, my bad

native tide
#

or should

        self.param1 = request.args.get('param1')
        self.param2 = request.args.get('param2')

pull these paramters?

opaque rivet
#

Generally speaking, you would add params to the __init__ method. But since this is Flask and iirc views don't need a request param as it's implicitly passed to the view. I don't know how, that's the inner workings of Flask which I don't work with. I'd write some tests to see if the request is passed to the class in this case

native tide
#

awesome cheers mate

lofty sigil
#

How do to force a socketio session to close from the server side?
Using Flask-socketIO on the server

late gale
#

mind if i say why frontend frameworks are occured while I will only prefer frontend frameworks if they are responsive without using media queries so developing on frontend framework gets ur website into fully responsive
but if all frontend frameworks i use media queries then why i even use frontend frameworks, I genuinely prefer backend frameworks
just an opinion and my point of view

opaque rivet
lofty sigil
#

Thx nicky. I should have gone through the docs a bit more deeply 😓

opaque rivet
#

hey guys - I'm confused about the build syntax of docker-compose files:

version: '3.3'
  # services
  backend:
    build: .
    command: python manage.py runserver 0.0.0.0:8000
    ports:
      - "8000:8000"
    depends_on:
      - db

  frontend:
    build: .
    command: cd frontend && npm run dev
    ports:
      - "3000:3000"
    depends_on: 
      - backend

So I know that each service needs its own image from docker hub, or a Dockerfile to build from. My backend is python and my frontend is node. Do I need two seperate dockerfiles for each?

lost heath
#

I have a basket link /bag?dwcont=“queryhere”
Then when you click checkout the “queryhere” changes and I’m not sure how I can find how to get the right one to post to the next request

late gale
opaque rivet
#

pure html and css also don't make your site responsive, that's your task to do.

late gale
#

i know

#

what i meant is

#

I don't find frontend frameworks worth if they can't do responsiveness

#

so why someone shall use frontend framework if u gonna write the same as html and css

opaque rivet
#

Because they have other features.

late gale
#

Elaborate

opaque rivet
#
late gale
#

and performance u can achieve that using html

solemn glacier
#

ben

#

suggsted way of communicating with flask server/api through a web page already loaded ie js

#

curretnly use basic fetch

#

no libraries

#

what you reccomend?

late gale
#

what i meant that i can use backend frameworks without using frontend frameworks if we're talking about data

opaque rivet
late gale
#

and performance u can achieve it using html

late gale
nimble epoch
#

of course you dont need any kinda frontend framework. if you want a kinda real time communication or some dynamic pages you use those frameworks

opaque rivet
late gale
#

then what frontend frameworks can do that vanilla css or html cant do

opaque rivet
#

Do some research and you'll find out. Use vanilla JS to manipulate your DOM and you're modifying the entire DOM document, use React and you only manipulate the VDOM element which is much less work.

#

Thus better performance.

#

Simple state management and memory leak management

opaque rivet
late gale
#

so frontend frameworks from what i learned that it makes ur website faster

#

do frontend frameworks have any related SEO thing

#

does it improve SEO

#

i will make some researches

opaque rivet
late gale
#

what about if website is both rendered like it has django and react as an example

#

will that improve SEO ?

#

or u need to improve SEO in both frameworks so it improves seo of the whole site

opaque rivet
#

SEO is really a product of your site's architecture

late gale
#

ok cool

#

i gonna make more researches about it and see about React or Vue

slim skiff
native tide
slim skiff
#

it's literally serverside rendered html being used by a frontend framework

opaque rivet
#

yeah you're right

native tide
opaque rivet
#
version: '3.3'

services:
  db:
    image: postgres
    volumes:
      - ./data/db:/var/lib/postgresql/data
    environment:
      - POSTGRES_DB=postgres
      - POSTGRES_USER=postgres
      - POSTGRES_PASSWORD=postgres
    ports:
      - "5432:5432"

  web:
    build: .
    command: python manage.py makemigrations
    command: python manage.py migrate
    command: python manage.py runserver
    ports:
      - "8000:8000"
    depends_on: 

Finally made my containers. Holy crap the amount of trouble I had this was ludicrous...
My server is running on port 8000, but how come if I go to 127.0.0.1:8000 nothing is found?

opaque rivet
#

fixed it - it turns out 0.0.0.0 is different to 127.0.0.1, does anyone know why?

quick cargo
solemn glacier
#

to reiterate, dont use 0.0.0.0 for dev or prod unless you know what youre doing

#

127.0.0.1 if for your localhost interface, 0.0.0.0 will bind to that as well as your nat address for example 192.168.1.50

quick cargo
#

note that with docker you will always need to bind to 0.0.0.0 if you want the thing in the container to be accessible from anywhere other than itself

solemn glacier
#

sorry didnt check context

opaque rivet
#

Hmm, since containers run on the same OS and same kernel, how come they can't access 127.0.0.1?

#

Wouldn't the containers still be running on the same machine?

quick cargo
#

yes however their environments are virtualised

#

each container by default has a seperate network so each container is seperated

#

in the case of compose a single compose has a network and the services can see each other providing you bind to 0.0.0.0

#

in the case of docker each container acts like it's a different machine

solemn glacier
#

so the container with its seperate network will need to bind to 0.0.0.0 to be accessible both by itself through localhost, and through the host machine through nat is my guess?

#

i havent used it much

quick cargo
#

a container can access itself via 127.0.0.1 or localhost

solemn glacier
#

right

#

and the host must access through some interface is it on the same nat

quick cargo
#

its just if any other container wants to access it, it must bind to 0.0.0.0 which exposes it to what ever network bridge it's connected through

#

if you have a shared network all containers on that network can then access the container

solemn glacier
#

probabl some higher level docker stuff in there? or can you connect directly through natted networks in between docker containers

#

on one machine

#

oh ok

quick cargo
#

Docker network is very complicated in places

#

and then if you want to expose any of those containers to the outside world you need to use the ports section of compose or the -p flag to tell docker to expose the given port on the external network to the given port on the internal network

solemn glacier
#

so the docker er

#

what is it

#

the container on the host

#

the docker app called

#

the main app not the instance

#

nvm, i'm going to google it

opaque rivet
#

Ah I see. So docker compose creates an image with it's own network, so if you run the django server on 127.0.0.1 it will only be accessible by the image and not the host machine. Thus you have to run on 0.0.0.0 to be accessed by other machines.

Thanks a lot. I need to pin these comments and write them in my notebook. You guys are genius!

solemn glacier
#

you could run it on the docker images nat address (assuming i understand this right and it has one) and connect through that internally on the image as well. if you bind to both localhost (127.0.0.1) and your nat address it will allow faster transfer when your image is using the localhost route

#

i think you can create groups and things on docker probably network segments

#

i havent used it in a long time

quick cargo
#

err sorta

#

if you bind to localhost nothing can access that container's thing regardless

#

only itself

#

like i said, they act like their seperate machines

opaque rivet
#

Tbh I know nothing about networking, i didnt even know what 0.0.0.0 was. How did you guys learn your mojo?

quick cargo
#

trail and error and debugging docker networking issues 😅

#

You can think of each docker network like a house

#

each house has a main router (the network itself and docker managing it) and then each PC (container) is connected to that

solemn glacier
#

i dont know but i remember learning about 0.0.0.0 was impactful

#

i must have realised i was exposing something on nat that should have been local

#

not that it maters

#

but just a shocker

opaque rivet
#

@quick cargo so it's the docker image which has its seperate network to the host machine - and the containers query it like an API? (iirc docker had some sort of restful api orchestrating things)

quick cargo
#

sorta yeah

#

Docker wraps this thing called containered

#

containered is what actually does the containerizing and virtualization

#

but Docker has a dameon server that has a api that tells it how to manage the containers and control it

#

So all docker compose and docker are as CLIs are python scripts interacting with that API

opaque rivet
#

You guys explained it really well. I've had a headache all day from docker. Thanks so much.

Do you think having abstract knowledge of docker is enough? If not how can I learn a bit more about the inner workings?

quick cargo
#

generally i wouldnt worry about the inner workings

#

because it's incredibly complicated

night agate
#

hey guys i want someone who know how to design a website so we can make a small project
i want someone who is a little beginner, also a beginner

opaque rivet
#

@quick cargo alright. Thanks a lot. If you had a blog, I would read it all day :D

quick cargo
nimble dawn
#

Can anyone tell me about

#

How to make database

#

And edit it with sql

calm plume
#

Maybe you want to ask in #databases to learn the basics

nimble dawn
#

Is access good for database

nimble dawn
safe oasis
#

How do I solve a captcha on my pc that my request received

limpid nacelle
#

i have. question but i'm not sure how to put it, i want to make a admin login form but i have 0 clue on how to make it login, i have the text boxes inputs etc but i want it to redirect to a page only if he has logged in

#

basicly i want to make a admin login form

solemn glacier
#

which framework are you using for web

limpid nacelle
#

flask

opaque rivet
#

if I set environment variables in my docker-compose.yml, can I access them with os.environ["ENV_VAR_HERE"]?

limpid nacelle
#

eh

#

you can use .env

#

and use os.getenv("ENV_VAR_HERE")

#

.env as the file

#

you have yml now

opaque rivet
#

I guess I could do .env but I wanted to specify environment vars in the compose file. But I think os.environ will be able to access them, I don't see why not

limpid nacelle
#

i'm not familiar with yml or os.getenviron

#

only with .env and os.getenv

#

i don't use the module too much

woeful swan
#

need help with django custom fields?

#

documentation is hard to understand, can someone provide tutorial links for this. Unable to find good result in google

limpid nacelle
#

i don't use django

#

it's too complicated

#

for me

quaint holly
#

help me in flask sql

#

class User(UserMixin, db.Model):

__tablename__ = 'users'
id = db.Column(db.Integer, primary_key=True)
username = db.Column(db.String(100), unique=True, nullable=False)
email = db.Column(db.String(250), unique=True, nullable=False)
password = db.Column(db.String(100), unique=False, nullable=False)
# back_populates='name_of_relationship_on_other_model'
# posts = relationship("BlogPost", back_populates="author")
comments = relationship("Comments_db", back_populates="comment_author")

class BlogPost(db.Model):
tablename = "blog_posts"
id = db.Column(db.Integer, primary_key=True)
author = db.Column(db.String(250), nullable=False)
title = db.Column(db.String(250), unique=True, nullable=False)
subtitle = db.Column(db.String(250), nullable=False)
date = db.Column(db.String(250), nullable=False)
body = db.Column(db.Text, nullable=False)
img_url = db.Column(db.String(250), nullable=False)
# author_id = db.Column(db.Integer, db.ForeignKey("users.id"))
comments = relationship("Comments_db", back_populates="parent_post")

class Comments_db(db.Model):
tablename = 'Comments'
id = db.Column(db.Integer, primary_key=True)
text = db.Column(db.String(250), nullable=False, unique=False)

author_id = db.Column(db.Integer, db.ForeignKey("users.id"))

post_id = db.Column(db.Integer, db.ForeignKey("blog_posts.id"))

parent_post = relationship("BlogPost", back_populates="comments")
comment_author = relationship("User", back_populates="comments")
stiff karma
#

Google it

quaint holly
#

i have

#

a lot

#

author_id returns NULL

opaque rivet
#

@quaint holly author_id of which table?

pseudo dagger
#

Hello guys, quick question:

#

Does any body know of a "roadmap" to follow for django + backend development?

#

I'm trying to build an API

empty junco
#

u got me

pseudo dagger
#

Oh wow, how funny. You should be a comedian.

#

WOW

#

I'll do some google instead.

calm plume
#

If you want to mess around, this channel is not the place. This is an on-topic channel about web development.

violet pond
#

@manic mortar I have removed your messages. Please read and take note of this ^

stable hemlock
pseudo dagger
#

Thanks! I'm trying to build an API that takes a document located in the C:\ drive,scrapes that document, turning it into a database and uploads the database registers to AWS.

zenith rose
#

How can I login to google using firefox with selenium

#

since I always get a error

#

` driver.execute_script("window.scrollTo(0, 1000);")
time.sleep(1)

driver.execute_script("window.scrollTo(0, 1000);")
loginchrome_input = driver.find_element_by_xpath("//input[@type='email']")
loginchrome_input.clear()
loginchrome_input.send_keys(ChromeEmail)
time.sleep(1)

driver.find_element_by_xpath("//button[@class='VfPpkd-LgbsSe VfPpkd-LgbsSe-OWXEXe-k8QpJ VfPpkd-LgbsSe-OWXEXe-dgl2Hf nCP5yc AjY5Oe DuMIQc qIypjc TrZEUc lw1w4b']").click()

time.sleep(1)

passchrome_input = driver.find_element_by_id("Passwd")
passchrome_input.clear()
passchrome_input.send_keys(ChromePass)

time.sleep(1)

driver.find_element_by_id("signIn").click()`
#

thats my script currently

#

I also switched to using geckodrivers instead of being on chrome with no luck

versed python
#

I suppose here driver.find_element_by_xpath. That is because classes applied to element in most google webpages are obfuscated, so they change on every request. You will have to use a different strategy to locate the element.

bronze oak
#

The channel has a lot more content related to API development using django.

dusk portal
#

why do we need to create poll directory in django is it necessary if yes so why cez i made app run without take and no issues was in that

#

;-;-;-

broken wren
#

how can i make letters hide and the visible to the right
animation with css keyframe

opaque rivet
opaque rivet
inland oak
#

quite detailed one.

#

Feeling myself overwhelmed and with headache

#

giggles, MD5 and why not to use it, nice name

hallow iron
#

guys, how to create a web with python?(not HTML)

nimble dawn
#

We can convert Adobe xd file into html

#

??

#

And get the code

thorn igloo
surreal portal
#

I heard Flask 2.0 is out!

inland oak
#

yeah and not only that

#

a whole array of important updates with it

#

Jinja 3.0, Click 8.0

#

and Flask finally supports async

surreal portal
inland oak
surreal portal
#

I suppose that might break some Flask extensions too

inland oak
#

it is more of a matter, that we have a choice to use them only with old Flask now

#

eh

#

is Nginx really that cool?

#

not really liking Nignx(

#

with docker-compose it can be more tollerable I guess

lean saddle
#

where do i ask a simple html css question

calm plume
#

Right here is fine

lean saddle
#

i need to write "Black Tea" but we cant use spaces in <div id >, any fixes
code for button

<li class="tm-paging-item"><a href="#" class="tm-paging-link active">blacktea</a></li>

the div it will show

 <div id="tm-gallery-blacktea" class="tm-gallery-page">
calm plume
#

You could do black-tea

lean saddle
#

didnt work

calm plume
#

Where?

#

The second or the first?

lean saddle
#

i did on both

opaque rivet
#

I'm a bit confused on docker volumes. If you create a volume, am I right in saying it maps a directory on the host machine to the container? So any changes in the host directory will update the container in real-time? (I'm looking to hot-reload my containerized react app).

lean saddle
opaque rivet
lean saddle
#

any hint on how i can do that

calm plume
#

Ids should only be used on one item (I have no idea if it works to put them on two, but one is better)

opaque rivet
lean saddle
#

ohh ok thanks

native tide
#

HTML and CSS are hard as ffffffffff

proper mural
#

hi everybody i have question about pictures in html !
when i write a code about putting an picture in html it doesent show me in the result :(
do anybody know something about this to help me ?

marsh canyon
#

the path/url for the image is prolly wrong

#

or maybe you forgot to refresh the page

#

or the syntax is wrong

proper mural
marsh canyon
#

show code

proper mural
#

i Exactly copy past the code that is in the tutorial but it doesent work

marsh canyon
#

have you downloaded the image as well?

#

or using a diff image?

proper mural
proper mural
marsh canyon
#

do you have img_girl.jpg in the same folder as the html file?

proper mural
#

i got it

#

i think the problem was this

#

thank for your help :D

marsh canyon
#

👍

lean saddle
#

@opaque rivet or @calm plume im terribly sorry for the ping but isnt there any way i can pass id of the div from href or something instead of editing my entire code,

<li class="tm-paging-item"><a href="#" class="tm-paging-link active">blacktea</a></li>```
 cause i just want the text Black Tea there
#

id name doesnt matter

celest shard
#

hi can someone help to build chat bot with python

#

With help of Flask

quaint holly
#

@celest shard

#

You know AI?

#

also can someone help me detect changes on flask templates

celest shard
#

@quaint holly Not good with AI and Flask . i had knowledge at Django and Vuejs

quaint holly
#

then give up on the project and start learning

opaque rivet
odd terrace
#

flask or django?

I know i want to learn one of them, but im not sure which.
over time i want to incorporate the use of react to build shopify-esque sites for small companies in their major period of early growth.

Which of the two is best for this?

inland oak
odd terrace
#

learning web dev or learning how to build python web backends?

inland oak
#

they have two opposite architectures

#

Flask is microframework = almost empty field to which you include everything one by one, while learning how to use it

#

Django is battery included = everything is already tuned and setup there, better to have previous experience to get it better

odd terrace
inland oak
odd terrace
#

alright, thank you. I'll start with flask

inland oak
odd terrace
inland oak
#

but with Django it is much more right

odd terrace
#

alright, thanks a lot man!

median loom
#

i've just learned that django is synchronous

#

that means it processes requests one by one right?

surreal portal
#

Yeah

#

A synchronous process means you can only execute a function in a thread at one time

#

While an asynchronous process means you can execute a function and get the response only when a promise is fulfilled.

surreal portal
#

And now that Flask supports async, we can do some interesting stuff on it

quick cargo
#

technically flask has been async for a while

#

it just wasnt asyncio based concurrency

opaque rivet
#

why can't you have long-polling with a synchronous server? Can't you just delay the response?

quick cargo
#

you can

#

it just makes scaling more awkward

#

because you lock up that thread for the period of time you're polling for

opaque rivet
#

so does that mean you won't be able to process other requests while you're polling?

quick cargo
#

well it just means that thread wont

#

but things like Django spawn a thread for each request

#

so generally it still can handle other requests

#

Long polling just isnt something i recommend for most things as it just creates alot of awkward scaling patterns rather than be useful

#

you're better off just using intermittent polling

opaque rivet
#

oh nice, just learnt something new. So I guess long-polling on a sync server would be really bad as you scale because your server would fail as soon as you've ran out of threads.

#

I guess that's the same reason why you can't have websockets on wsgi servers?

quick cargo
#

you can

#

the issue with WSGI was that it was just never designed for it

#

so websocket support with the interface is a bit of a hack

#

generally long polling sucks at scale for most things

opaque rivet
#

if you're hacking away at it wouldn't you be limited by the number of threads though, like long polling?

quick cargo
#

I mean yeah, but these are OS threads so you can run alot of them

#

async can easily have the same / a worse issue though

#

because by default you're limited to 512 selectors with the selector setup for checking socket readyness

opaque rivet
#

OS threads? I haven't heard of them. What does it mean?

quick cargo
#

they're basically threads managed by the operating system rather than the cpu

#

so you can in reality have hundreds of these threads

#

the OS swaps cpu time between them

#

In python you dont get any CPU advantage though because of the GIL

#

but they're good for concurrency

opaque rivet
#

so in general when we talk about "threading", are we referring to using another CPU thread?

quick cargo
#

in python's world no

opaque rivet
#

😮

quick cargo
#

in python's world their referring to OS threads

#

which are still bound by the GIL

#

hence why they are able to have the shared state

opaque rivet
#

oh cool, I need to read about the GIL. I always thought that it referred to using new CPU threads.

#

I guess I should just think of threads as an instance of "execution" of code

quaint holly
#

Hello people can someone help me in sending data from JavaScript to My flask route as json

#

@quick cargo

opaque rivet
quaint holly
#

Uh yes

valid prairie
#

hey, should i add migrations into git?

mint folio
valid prairie
#

ok thx

tough briar
#

why does this work

#

but this dosent

#

(in flask if it wasnt clear from the img)

#

nvm found it print(request.values.get("key"))

native tide
#

Hello guys, I’ve never built a full website before from start to deployment and was trying to find pointers about how to go about building an e-commerce website. Where do I start from, should I use a cms if so which? Backend/frontend tech? How and where to deploy?

#

Everytime I sit and start thinking about how to go about it I just get lost in my thoughts

dusky moon
#

for some reason when im referring to my second html page it isnt recognising the directory, the tutorial i am following is on MAC so just wondering if anybody knows what the windows version would be?

#

im using flask btw

#

also when i made a folder under static, naming it CSS for some reason the folder names went like static/css

quiet garden
#

**How can I make my flask application verify if a code is correct or not? **

So I have a flask application connected to my html file...
this html file has a form that upon submitting information in the input box it is sent to my flask application and printed.

what im trying to do is verify if a code is correct... if it is, it redirects to another page, if its not... it will return access denied...
Heres my progress:
python:

@app.route("/testing", methods=["POST","GET"])
def adminRequest():
    auth_code = "Example" 
    input_grab = request.form.to_dict(flat=False)
    print(input_grab)
    cliWeb = DiscordWebhook(url=webhookurl, username="Access Request", content="User attempted access for 'Admin - Dashboard'")
    em = DiscordEmbed(title="User Requested Access to Admin", color=242424)
    # wem.set_description(content or ":x: | No Data Found")
    em.set_description(input_grab)
    em.set_footer(text="Authorization provided by scsi")
    em.set_timestamp()
    cliWeb.add_embed(em)
    # ws.send("Accept? or Deny?")
    wres1 = cliWeb.execute()
    if input_grab == auth_code:
        return redirect("/test2")
    elif input_grab != auth_code:
        return "<h1>Access Denied.</h1>"

Html:

<body>
    <label>Enter authorization ID</label>
    <form action="/testing" method="POST">
    <input type="text" id="authorize" name="authorize" placeholder="Enter AuthID to Continue..." required>
    <br><hr>
    <input type="submit" name="submit" class="submit action-button" value="&nbsp;submit">
    </form>
</body>

How do i do this?
(if its better, you can chat with me about this in #help-chocolate )

#

the webhook just sends if someone is trying to access the page

#

dw abt that part

#

this is all flask btw

native tide
#

Python Master race, I need your help:

let's say that I make a Google Extension
and it uses Google Translate
I make my users pay for the extension
but when it comes to the translation functionality
it simply automates the user's Chrome Browser to use the Translate features instantly and accordingly to its set of rules with the help of Javascript
so my question is:
am I allowed to make a commercial service
even though it just uses Google Translate from the User's browser, for free? (Instead of something like Google Cloud Platform Translate API)

solemn glacier
#

allowed as in Google TOS?

safe oasis
#

how do I render a current unsolved captcha to my website so I could solve it there? similar on how 2captcha sends my captcha to their workers

calm plume
#

@opaque rivet Once you figure out your docker stuff, if your project is open-source, would you mind sharing your Docker config link? I'd like to dockerize my React/Django app soon and would love to take a look

vestal hound
#

not a Python question

twilit needle
#

I am planning on creating a search engine with python, have been doing research for a while. I am planning to scrape the web with broad crawlers in parallel (using scrapy), and I am planning to use django for the api (rest framework). Django haystack works well with full-text searches, I would have to tokenize and optimize the crawled data before storing it in my database (haystack document with template). However, django doesn't have native support for nosql. Obviously I cannot use relational databases for writing chunks of data and keeping it fresh at the same time.

What are my options?
Any suggestions?

glad patrol
#

can someone help me regading .net code understanding

worthy lake
#

Is it possible to select these values from the root element with JS and CSS selectors? I don't know how to do that. with :root

I guess it's technically part of <html> but even if I select that how can specifically select the value, for example, at --hue...

#

I suppose I could alias the element at slightly deeper node, select that, and use the alias where i need it changed.

outer apex
worthy lake
#

be able to adjust the --hue value from JS. But I realized all I have to do is like

body {
  background-color: hsla(..)
}

and then select that in js and insert a changed value.

#

I was just using the root node when it was static

#

so like you could do.... for example... let hue = document.querySelector('--hue')?

#

because in the end its a property not a selector

#

its really just a placeholder for what will be a property

#

no i guess it counts as a property.

#

wwait

#

maybe

#

let html = document.querySelector('html')
html.hrmmm

#

let me see

#

I legitimately dont think its possible to edit the :root selector once the file is linked in. Buts its not a big deal.

#

If you select ':root' from js, it gives you the same thing as if you did 'html'

#

But there is no information on those css placeholder/vars that are assigned with --

#

I'm pretty sure that is why people hesitate to call thjose vairables

#

Even though it seems like they are.

#

actually, yes it is a big deal

#

I use those placeholders in too many places to manually change them all :/

#

No, those are different than what im doing

#

im using custom properties, not placeholders

#

i mixed up terms

rapid spindle
#

is anyone know how to use inner join with django ORM? i mean, i know how to use it but i don't have any ideas with how can I use it in my case. my models created a table "affectationGroupe", this table is just used for joining the table groupes and users. But it doesn't really exist in my models, how can I tell to django that's a table?

worthy lake
#

i dont understand why i cant do document.querySelector(':root').style.--hue

rapid spindle
#
class Utilisateur(models.Model):
    nom = models.CharField(max_length=30)
    prenom = models.CharField(max_length=30)
    login = models.CharField(max_length=30)
    password = models.CharField(max_length=30)
    num_izly = models.IntegerField(null=True)
    statut = models.IntegerField(default=1)
    email = models.EmailField(max_length=100)
    affectationGroupe = models.ManyToManyField(Groupe)

    def __str__(self):
        return self.nom```
worthy lake
#

definitive answer to my bit

worthy lake
#

lol, thats pre-processors. you can do it

#


// get variable from inline style
element.style.getPropertyValue("--my-var");

// get variable from wherever
getComputedStyle(element).getPropertyValue("--my-var");

// set variable on inline style
element.style.setProperty("--my-var", jsVar + 4);
#

nope I was wrong again, turns out they were lying let test = document.querySelector(':root').style.getPropertyValue("--hue")

test is ''

#

I'm considering having 360 css files where the only difference is one value being anywhere from 1-360 and then i can set the value by changing the file.

#

lol

#

only problem with that is i need the changes to animate, not refresh

#

The only other thing I can think of is pro grammatically assemble a list of elements that use the --hue and when I change it, I literally update every element with a for loop.

#

That is a depressing solution

#

to reiterate, what i want is

#
:root {
  --hue: 273;
  --width: 100%;
  --bright: 12%;
  --link-br: 73%;
  --hover: 22%;
  --fn-one: 'Audiowide'; /* [sR] This one is for artistic looking text */
  --fn-two: "Times New Roman", Times, serif;
  --fn-three: 'Kanit'; /* This one is more plain text */
  --fg-color: hsl(var(--hue),100%,89%);
  --bg-color: hsl(var(--hue),84%,var(--bright));
  --faint-color: hsl(var(--hue),64%,64%);
}
#

I want to change that --hue value from JS and have it affect everywhere in the css i am using that.

#

the 360 css files that all have one different value in one line would work...

#

lol

#

maybe

#

oh shit it works

#

You cant get the properties buy you can set them

worthy lake
graceful flax
#

Hi

#

I decided to build my social media app, that spreads across web, iOS and android