#web-development
2 messages · Page 156 of 1
@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?
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.
glad to hear... flexbox is great, someone in this channel actually recommended the game: https://mastery.games/flexboxzombies/ and that's how I learnt it. really nice stuff
👍
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>
Oh, nice interactive tutorial.
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.
I personally don't see why you need websockets for that, that can simply be done with an API.
You can use Django signals to dispatch channel requests whenever a database object is saved, updated, etc.
you dont need to have post.html template and yeah of course you can do this in that
My template is a lot more complicated, that was just for example. I have like 15 items per dict.
But does this mean that in the template all of the access needs to look like {{ post.title }} instead of just {{ title }} ?
that actually how you can access your data
oh signals...
I wanna use WebSockets because I want users to be able to see the data in the frontend as fast as they can, atleast this is what i came up with.
the whole point of this app is that users to able to see the data live, like they are in a chat app, the only difference is they wont chat, they'll ask and answer questions, like stackoverflow
But there is no way to pass the dict itself as the new context?
cause you have something like ```
posts = [
'item1': {
'name': 'Item 1',
'number': 10
}
]
are you really going to have so many users on there that you will even benefit from realtime questions? to me, I don't think you will. I think a realtime chat is more suited for websockets.
you can add object to your context when rendering a template
of course you probably wanna use databases for big data not objects
Okay, I think I'm catching on
Thank you
yaw
Yes i have* that many users
fair enough, then go for it
this is the website
by the way, if I want to setup ci/cd (github actions), will I have to run docker setup scripts?
it has its own language that replaces docker scripts
That site doesn't do anything
It's completely static for me. Can't even go to another page.
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
Yes its just the UI
wtf was that?
@dusk portal So what exactly are you trying to do?
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
Okay
Ignore the node thing
Ok
So what's not working with bootstrap?
It does
It affect the code?
<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
Ok i remember lol yes
Yes
Teach me a nice way to get frontend
Animated good (op) front-end
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
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.
The html code
Wait giving
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
I don't use Bootstrap, I usually use raw Tailwind and normal CSS
Oh , did u get nice looking frontend?
But I know how to use html, so I can spot basic issues if I see the code
I'm working on it
I'm working on one, although it isn't finished
U copy cdn from tailwind css
And copy code from tailblocks ?
Or code only from tailwind css site?
Oh i have heard about that
When i open site
It's on top
👀
Yes, the npm package is the best way to use tailwind
You don't need too
What should i do ;_;
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
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
I use Tailwind (Tailblocks) it's ez
But it don't have templates and things more
As Bootstrap has many things so many choices it is filled with content
If you're using Bootstrap, then you can't use Tailwind. Are you okay with that?
If you don't want to write any type of CSS, use bootstrap
Ok then i choosed Bootstrap
What's next step
Do you have your code?
It'll be really hard to do it without
But if you follow the docs, it should be easy
I have seen a 2hr tut. To use bootstrap
They r too long
btw, you can use bootstrap and tailwindcss, just import from cdn
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
how does tailwindcss differ from libraries like bootstrap/bulma?
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
by components you mean things like carousels, media cards, spinners etc?
Yeah, and buttons and tabbers and the such
ohhhh ok
It's better to code and make them urself
Imo, yes, but some people don't like doing that
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
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
That's very one sided
By saying sinple u mean only html?
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
Man css is for enhancing the look of the website
Yes
Which is something that not everyone needs
Some people are fine with basic websites with bootstrap
If they don't need then it's ok
Ah maybe u misunderstood me
it sounded like you were saying that using bootstrap is bad
Nah i got confused between 2 things
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
gotcha
i don't know the specifics, but tailwindcss has jit compiling, in terms of utility classes it's very comparable to bootstrap. I only use it for tailwindUI (tailwind components) which I paid $250 for. I like it.
if you wanna try tailwindUI out I can send you over my account
TailwindUI's free components are amazing too
using utility classes doesn't mean you don't know CSS. I use utility classes, and I know CSS. I'd much rather focus on the architecture of my app rather than writing convoluted css files
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?
Man i was talking about something else i got. A lil bit confused 🙏
Ask away, this is the right place
thanks!
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 ??
For beginners, which is more recommended django or flask?
Flask is probably easier to learn since it's a micro framework, but they do different things
Can you elaborate more on the difference? I’m stuck in which to learn first
On*
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
So wouldn’t it be better to learn django? Especially if I want to get into the software engineering world?
Django is better imo, yes
And it's used in production by a number of huge companies
For example, Django powers Instagram
Nice. Any valuable tutorials you can point me to?
The official Django tutorial is really good. And if you prefer videos, Corey Schafer has a good series on it
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 😦
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
@frail cairn run pip list too see installed packages
yep its on the list
hello world
@frail cairn you using a virtual environment? Maybe the package is installed on your personal machine and you need it in the virtual one
ok i’m learning how to do this
i wanna do something like this
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
bump
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 😄
fantastic. Going to learn best practices out of it.
looking at this awesome project, feeling myself as dummy once again.
https://www.youtube.com/watch?v=UgBbxE-M0tQ
Who needs friends when you've got knives?
EDIT: 100,000 views!
EDIT: 250,000 Views!!
EDIT: 500,000 VIEWS!!!
EDIT: 4,000,000 VIEWS!!!!!
Art from: https://goo.gl/Ku0ckr
Credits to CopyCatFilms for the silent movie title card template.
Listen on Soundcloud: https://goo.gl/TkqE2f
Download: https://go...
How do we configure a url with Django 3.2?
I love it! I just listened to the WHOLE thing!
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
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))
resulting urls:
http://yourserver/commodity/list
http://yourserver/commodity/get_main
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!
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
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
yeah but def given its popularity, will add pytest.
Do you guys structure your projects as a single django app or multiple?
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?
yeah I meant internal django app
answer remains the same then
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....
mm I keep separate models
but database remains shared, each app just has different tables and set of serializers/urls/views/tests
apps remain connected with foreign keys
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
redis/celery
kubernetes?
re: k8s, would you want terraform/ansible scripts?
This is amazing
If you plan to support k8s, just go with yaml files. Keep tf, and ansible separate. (Basically align with greater k8s community).
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?
my pref, k8s yaml
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.
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
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)
Yeah I have friends at these companies and they have similar scaffolding tools - eg Airbnb has a "make me a service" tool...with the aim to be consistent across the infrastructure
Thank you. That was a very convincing reply. Do you plan it as product with paid features ? What are you future thoughts , especially business ones rather than technical features?
At twitter, it was go/service - but a wizard. We started as 3-member team, but given my lack of UI or web-development skills then, I got moved to other project.
I am extremely tempted to try your tool. I am thinking of what to build 🙂
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…
Would would love it if you gave it a try...and would be great to hear your candid feedback! We have a demo todo app there you can play with...including a built-in live database/running API endpoints and test reports to help you as you build the schema...
Yup, I will start with a todo app using imagine.ai
me three, until I learned all features at least. It sort of acts like interactive tutorial.
WHAT LANGUAGES DO YOU USE FOR WEB DEVELOPEMENT
i only use django and flask (python ) and some sql for databases
- for frontend i copy from bootstrap and jinja2/jinja templating
oh nice , does bootstrap provides codes of css?
cuz i dont use boostrap
whole html
lo,
why?
ig u good at frontend or u r creating a very complex site
i only know html and css rn
i need to leanr js
until i dont know js i cant make a complete working website
u know what is bootstrap and tailwind(tailblocks)
idk but i can and i do
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
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
but isnt js the brain of the website
?
it contains js in the code
Hey guys I am looking to learn websockets with django and react can anyone suggest good resources!!!
idk i still want to learn js, html and css
sorry idk it
If anyone else knows do recommend
ur choice u should learn but dont waste much days in it , now a day its one page application technology
for django and react i suggest you the main official site
hmm
and for websocket go to readthedocs
of>
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
sadd ,im not ;-; i watch videos thats my weak point
😢
i exactly used to be like you. just give it a try
oh sure i will try but 1 problem
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
usually the topics are on top of page or title or subtitles
no idea but videos are only for beginners in my idea you can get more detail with docs
ok
as u say my bruh
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!
you want your data be updated everyday and be shown in your website, right?
based on the scraped data
Exactly! I want the script to run and the new iframes to be deployed to the Github Page
so i think you need a cloud platform cause github pages are for statics only i think
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?
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
Will do, anyways thanks for taking the time out to discuss it. Have a great day!
you use scrapy or selenium right?
Ive used Beatuiful Soup. It generates a list of 20 iframes at the end of the line.
Will def look into it once I get the website up and running!
def? view function?
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 .
@chrome trench actually it can be done with github actions and pages
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
@inland oak Thanks for the response! Happy to use Gitlab pages as well
.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
Wow, thanks! Reading up on Gitlab pages and the ymlfile you posted. Really appreciate your input @inland oak
whats up
u know flask??
a little bit
yes
mean backend
yes
so u know session ?
yes, its been a while since i've worked with flask session / auth stuff but shoot
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?
what is the question my friend
@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
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
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
can i stream it??
You want to have multiple levels of authentication?
ok imagine as i say 1 min
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?
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
when you say 1st and 2nd awhat are you referring to
you only need one login page for your website
1st = Task viewer
they are both on the same page
only task viewer have
send the function name and decorators for your views / route for the 1 page with 2 button
ok
is it dashboard.html?
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
@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
do you have a @app.route("/taskcreator")
@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')```
u a welcome.
We all help each other here.
One day I teach someone
Tomorrow someone (even the same person) teaches me
yes , task creator is working
login and taskcreator are working
login1
it has issues
wait
hero here
ur using login.html for two login route?
no error just some problems
and i know why also
but asking
u know this
ok
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
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
im having trouble because i stilldont fuly understand your problem, what is the 2nd panel and whats it for
it asks for password and if correct it should render taskhandler
and first is correct
ignore it
so login 1 access task creator, login 2 access task creator and task handler?
is that the goal
login = taskcreator and login 1= task handler
login and taskcreator works properly ignore
so you want to create a second
log in page, that redirect to the task handler
not the task cretor
but it doesnt work
ok listen
what's the difference between the Dockerfile and docker-compose? I know that Dockerfile creates the image
videos are better ngl they explain better
Yes
@native tide hi aryan
Talk here in English
I'm dm hindi
k
Afaik, docker compose is for defining and running multi-container Docker apps.
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)
this was my views.py
this is my forms.py
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
!code
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.
@calm plume thanks - so Dockerfile and docker compose are interchangeable?
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:
- Define your app’s environment with a Dockerfile so it can be reproduced anywhere.
- Define the services that make up your app in docker-compose.yml so they can be run together in an isolated environment.
- 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
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
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)
class Test:
@staticmethod
def test_route1():
return 'Hello world 1'
@staticmethod
def test_route2():
return 'Hello world 2'
thanks - so if I'm not mistaken, the dockerfile creates an image (which when ran, creates a container (essentially an OS with its own filesystem, networking and dependancies)) and with docker-compose, you can create multiple containers for different services. I'm following their docs creating the Docker file but I need to also run redis, etc. which is why I need docker-compose.
That sounds about right
so talking to ionos
they said "website builder has no capability of doing subscription payment systems"
unless i can find discord html code
hey, hero
Website builders will not give you a backend
You'll need to make the html/css yourself if you want payment systems
i want ;-;-;-;
Unless you hire someone to do it for you
Hello
also didnt people in here tell me to use ionos because they had a backend
yes u should know basic html css
You would need css and js to make it look good
Well maybe you could, but not as well as if you built it yourself
lmao
well i just spent 250$ + 60$ a month so they could do this, because everyone kept telling me ionos COULD do it
https://github.com/python-discord/bot/blob/main/docker-compose.yml#L27-L32 If you want Redis, here's an example from @lavish prism
docker-compose.yml lines 27 to 32
redis:
<< : *logging
<< : *restart_policy
image: redis:5.0.9
ports:
- "127.0.0.1:6379:6379"```
thanks - setting it up now 🙂
Good luck!
well ionos support is asking for something, so where can i find this
The best you could find is inspect element, but that wouldn't work
Since you don't have the css classes
so not possible at all then?
Lol what
?
Could do that here refers to
Yes
It COULD, but well? Not as well as manual
Yes u told i should choose bootstrap and i said ok
You said you wanted to do bootstrap, yes
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
Yes it's op
But u were telling something some trick to use it
all they said was "discord html code"
There was no trick
Just read the installation docs
Oh
How to make a custom URL with flask?
aren't all URLs custom? what is not custom URL?
but how do I do it
like
Just fifty messages ago answered
ops, it is Django
Flask slightly different
Check mega tutorial then
it will eliminate a lot of questions regarding Flask
hi
what is your question related to
i wanna develop my own website
ok
have you ever done before?
i know a bit about it. are you planning on flask or django
django
maybe somebody else may be able to assist you better than i would be able to, i have more exp with flask
then let's use it.
you don't have a specific problem? or just questions related to what you plan on building
what is your concern
@hollow bronze Hey, we do not allow for hiring here
where i can hire someone?
can i ask you about job?
R u expirenced with python?
Lol
@hollow bronze hey bro do u have exp in python
If u don't have so don't start with django
Start with flask
go to official website
should I use celery or should I use threading for background tasks like sending emails?
The simplicity of celery leads me to recommend it. You can have periodic cronjobs or tasks that run x seconds after an action.
You could also do it with threading, create a new thread on server-start and using something like python-crontab to schedule events (or have an indefinite loop querying for any available emails to send). The second option seems quite crude.
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?
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
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
have you guys ever moved your django project into one singular directory? I tried to do so and I'm getting ModuleNotFound errors.
you cant do that
you have to follow the Django structure it generates for you really
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
What will you host it on?
You can't really do that into one file directory as far as I know. As I being a HTML CSS Web Development Programmer I am not 100% sure.
I am a bit confused on what your trying to say. Are you trying to list "[ 'tomCruise':{ 'name': 'Tom Cruise', 'bio'" in a JSON File?
It's possible...you have the text file as a csv file
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.
are you in the right virtual environment
do you have SQLAlchemy installed? be sure to install the most recent version installed
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?
nvm should've just used psycopg2 🤦♂️
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
Difference between port and ip address?
hello guyz i was learning django for front end should i used front end framework or template based front end is good
??
ip address is the number address like 192.168.1.1 etc it use for identifying the computer in internet or LAN connection
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.
anyone here i need a help
what you need help with?
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}'
@nimble epoch a small issue if u r free for a while
oh sorry bout that
U don't know flask?
a little i dont remember well maybe something that are the same in every frameworks
route1 is not a static method
Thanks. Even if I remove the staticmethod decorator, it will still return same error
view_func=Client().route1
static-methods are methods which run on the class, instead of the class instance 👍
@opaque rivet how would i then pass parameters to the class instance?
view_func=Client(param1, param2).route1
How would that work with url views and separate modules?
or should
self.param1 = request.args.get('param1')
self.param2 = request.args.get('param2')
pull these paramters?
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
awesome cheers mate
How do to force a socketio session to close from the server side?
Using Flask-socketIO on the server
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
frontend frameworks don't automatically make your site responsive, that's your task to do.
Thx nicky. I should have gone through the docs a bit more deeply 😓
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?
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
I know that but It would be better if frontend makes ur site responsive automatically otherwise i prefer pure html and css
pure html and css also don't make your site responsive, that's your task to do.
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
Because they have other features.
Elaborate
ReactJS Features with ReactJS Tutorial, ReactJS Introduction, ReactJS Features, ReactJS Installation, Pros and Cons of ReactJS, AngularJS vs ReactJS, Reactnative vs ReactJS, ReactJS Router, ReactJS Flux Concept, ReactJS Animations, ReactJS Discussion, ReactJS Quick Guide, etc.
its better to use backend frameworks for anything relatied to data
and performance u can achieve that using html
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?
what i meant that i can use backend frameworks without using frontend frameworks if we're talking about data
Frontend frameworks are for the frontend, not the backend. I don't think you fully understand what they do and their uses.
and performance u can achieve it using html
tbh i will only value front end frameworks if they make ur website automatically responsive similar to bootstrap
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
You're comparing utility classes to front-end frameworks. They do different things 🤦♂️
then what frontend frameworks can do that vanilla css or html cant do
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
You do know that frontend frameworks don't replace CSS or HTML
ik that
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
it's not that simple. SEO is measured from a lot of factors, like if it's clientside rendered or serverside rendered. If you are interested look at React and its features, it's the hottest framework atm 👍
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
one page can be rendered by either the clientside or the serverside, not both
SEO is really a product of your site's architecture
hydration is what it's called, it is a thing
https://slambook-py.herokuapp.com hey its an django based application
it's literally serverside rendered html being used by a frontend framework
yeah you're right
https://slambook-py.herokuapp.com/ hey give it a try
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?
fixed it - it turns out 0.0.0.0 is different to 127.0.0.1, does anyone know why?
0.0.0.0 means bind to all the machine's external addresses. This makes it exposed to the public network / other computers not just the machine running the server.
127.0.0.1 is just localhost meaning it's self contained within the machine and isnt exposed anywhere other than the machine running it
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
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
sorry didnt check context
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?
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
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
a container can access itself via 127.0.0.1 or localhost
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
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
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
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
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!
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
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
Tbh I know nothing about networking, i didnt even know what 0.0.0.0 was. How did you guys learn your mojo?
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
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
@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)
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
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?
generally i wouldnt worry about the inner workings
because it's incredibly complicated
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
@quick cargo alright. Thanks a lot. If you had a blog, I would read it all day :D

Maybe you want to ask in #databases to learn the basics
Is access good for database
Ok didn't knew there was a database channel
How do I solve a captcha on my pc that my request received
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
which framework are you using for web
flask
if I set environment variables in my docker-compose.yml, can I access them with os.environ["ENV_VAR_HERE"]?
eh
you can use .env
and use os.getenv("ENV_VAR_HERE")
.env as the file
you have yml now
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
i'm not familiar with yml or os.getenviron
only with .env and os.getenv
i don't use the module too much
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
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")
Google it
@quaint holly author_id of which table?
Hello guys, quick question:
Does any body know of a "roadmap" to follow for django + backend development?
I'm trying to build an API
u got me
If you want to mess around, this channel is not the place. This is an on-topic channel about web development.
@manic mortar I have removed your messages. Please read and take note of this ^
there are good youtube tutorials out there.
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.
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
what's the error you are getting?
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.
Hey, I recently watched this tutorial and found really good and easy to understand. Hope you find it useful too. https://youtube.com/playlist?list=PLLRM7ROnmA9HzbIXYN6D3wOZ0wUrqNs_d
The channel has a lot more content related to API development using django.
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
;-;-;-
how can i make letters hide and the visible to the right
animation with css keyframe
to decouple your application into smaller, more manageable chunks.
Oh nice. This is more detailed map than I have
quite detailed one.
Feeling myself overwhelmed and with headache
giggles, MD5 and why not to use it, nice name
guys, how to create a web with python?(not HTML)
i think you have to do the converting by writing the code yourself
I heard Flask 2.0 is out!
yeah and not only that
a whole array of important updates with it
Jinja 3.0, Click 8.0
and Flask finally supports async
Holy smokes. Click too?
Yup
I suppose that might break some Flask extensions too
Nah, all extensions have written into them which version they support
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
where do i ask a simple html css question
Right here is fine
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">
You could do black-tea
didnt work
i did on both
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).
https://www.free-css.com/free-css-templates/page263/simple-house
this is the page im wrking with (dont judge), black tea will replace pizza in the secondary nav bar
"Black Tea" is not a valid id, that will give your div two ids: Black and Tea so you'll have to change your ids (and css) to reflect black-tea as dawn said
any hint on how i can do that
If you're putting it on both items, use a class
Ids should only be used on one item (I have no idea if it works to put them on two, but one is better)
give your div the id black-tea then you can style it in your css file:
#black-tea{
...
}
ohh ok thanks
HTML and CSS are hard as ffffffffff
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 ?
the path/url for the image is prolly wrong
or maybe you forgot to refresh the page
or the syntax is wrong
no i didnt
show code
i Exactly copy past the code that is in the tutorial but it doesent work
yeah
<img src="img_girl.jpg" width="500" height="600">
do you have img_girl.jpg in the same folder as the html file?
aha
i got it
i think the problem was this
thank for your help :D
👍
@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
You know AI?
also can someone help me detect changes on flask templates
@quaint holly Not good with AI and Flask . i had knowledge at Django and Vuejs
then give up on the project and start learning
I'm not sure what your question is. can you rephrase? also just so you know, having the id or class Black Tea means the div will have two id/classes, Black and Tea respectively.
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?
flask for learning
django for building
learning web dev or learning how to build python web backends?
getting a hang of python web frameworks
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
kinda like how you would do some tkinter before doing pyqt5?
yes, good anology
alright, thank you. I'll start with flask
at least If I googled it right and tkinter is 'build GUI on your own'
and pyqt5 is having wizard tools for visual setting up, right?
uh im not sure
my experience with tnkinter is that theres not a whole lot of prebuilt components but its fairly easy to build your own, whereas with pyqt5 the components are there and they're complex, but you'll be digging through page after page of docs if you dont know what you're doing
tbh that can be said about both frameworks
but with Django it is much more right
alright, thanks a lot man!
i've just learned that django is synchronous
that means it processes requests one by one right?
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.
https://docs.djangoproject.com/en/3.2/topics/async/
django supports async from 3.2
https://docs.djangoproject.com/en/3.2/howto/deployment/
deployment instruction includes how to do it with ASGI
And now that Flask supports async, we can do some interesting stuff on it
oh ok thanks
technically flask has been async for a while
it just wasnt asyncio based concurrency
why can't you have long-polling with a synchronous server? Can't you just delay the response?
you can
it just makes scaling more awkward
because you lock up that thread for the period of time you're polling for
so does that mean you won't be able to process other requests while you're polling?
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
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?
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
if you're hacking away at it wouldn't you be limited by the number of threads though, like long polling?
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
OS threads? I haven't heard of them. What does it mean?
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
so in general when we talk about "threading", are we referring to using another CPU thread?
in python's world no
😮
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
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
Hello people can someone help me in sending data from JavaScript to My flask route as json
@quick cargo
Uh yes
hey, should i add migrations into git?
Yes
ok thx
why does this work
but this dosent
(in flask if it wasnt clear from the img)
nvm found it print(request.values.get("key"))
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
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
**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=" 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
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)
allowed as in Google TOS?
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
@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
this is a legal question
not a Python question
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?
can someone help me regading .net code understanding
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.
What are you trying to do here?
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
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?
i dont understand why i cant do document.querySelector(':root').style.--hue
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```
definitive answer to my bit
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

