#web-development
2 messages · Page 152 of 1
hii
i am testing my views with postman. I am not able to retrieve the data i send in a post request
glitch
Yes I have used them before. They are very powerful together. I recommend u use DRF for the Django APIs
yoo bro i've a doubt
how can i become a backend developer after learning python
what do i have to do next i've compleated full begineer course
@shy bane just first learn flask as it is good for begginers in that u will learn about databases and little php learn that and u should know little html and css so do all these stuff and after all this go to Django and learn that + keeping practicing and making projects day by day u will become pro in it
here this is for all who want to learn web dev from python and go to advanced
Hello, I'm trying to create sign in functionality for my Django website, but even if I enter valid information, I get an error. How can I fix this?
can i know error?
I'm not getting an actual error, but an error message is created from my for loop instead of redirecting me when the information is valid
The information is valid, but Django keeps telling me that the information doesn't match.
Maybe I'm using the wrong input fields?
I'm using the default AuthenticationForm though...
rename this in ur templates folder bro so if it shows temp not found so it means prblm was in html
do that
That's not the error I am getting though.
The views all work, it's that it doesn't recognize that the passed info is valid
Even though the form is valid, it prints the errors instead of logging me in correctly.
The form will throw this error if the authenticate call failed for some reason
Specifically, here:
if username is not None and password:
self.user_cache = authenticate(self.request, username=username, password=password)
if self.user_cache is None:
raise self.get_invalid_login_error()
else:
self.confirm_login_allowed(self.user_cache)
I'm very new to Django and following a tutorial by Corey Schafer, the only notable difference I have is that I split up the form instead of plotting it all at once (so I can style it)
So I'm quite lost as to how I can prevent this..
ah... now it worked... It seems I need to show the view like this
yes
hey i am using beautiful soup to parse some data
but there are too many div tags used
so i checked the div and class of the specific data and got None
then i checked the parent div
which has triple dots at many places
i want the info inside it
how to view the child tags inside this span
wlr#9602: wlr#9602`: wlr#9602: ``wlr#9602: ``Stehack_#7605: !code`````
wlr#9602: wlr#9602`: wlr#9602: ``wlr#9602: ``Stehack_#7605: !code`````
How can I get a value from one model and show it on another model in Django?
My User's Profile model has a boolean value of user_verified, and I want to display this on my Product model.
(My final goal is to show on a product whether the author is verified or not using a badge icon)
If someone can help me, feel free to @ so I don't miss it :)
urgh, those damn static files
why can't they be shown in Gunicorn correctly%?
I already even collected them to one folder
I don't want raising nginx for this, it still sort of development
whitenoise!
gunicorn + whitenoise is a quick and easy combo for simple apps
already 'hacked' django settings to do that
I'll be sure to remember a better way though
better to write into issues
yup
your product should have a ForeignKey to the User model, where you can simply call it like:
Product.objects.get(...).author.user_verified for example
thanks. easy to use way)
I guess it is less dumb way than writing
# url(r'^static/(?P<path>.*)$', django.views.static.serve,
# {'document_root': settings.STATIC_ROOT}),
I feel like it is almost the same though
oh, it has caching and etc
all right, perhaps it is not the same
is there a route for this?
Why don't you link author to profile instead of user?
I'm following a tutorial which linked it to User (to display the name). I also can't seem to import Profile unless I use apps.get_model
prob better to ask here
Check for any circular dependencies
if i wanted to try web development should i learn django or flask
i have no idea
what they are
i just searched it up on youtube and all the tutorials have one of them
Dont go into flask or Django if you're completely new to web dev, learn html and css first
html and?
No circular dependencies, these are my only imports in both models.py files:
from django.contrib.auth.models import User```
or just html
html css javascript
Did you set AUTH_USER_MODEL in settings?
What does that do?
I didn't create a custom User model, I'm using the default one and just adding a Profile model to it
it can expose your chosen model to get_user_model()
also, you should use Profile in the Product foreign key because you can get a User from their profile, letting you access both properties
you can build simple HTML pages and style them with CSS. i suggest you start messing around with what you can do in a webpage with just that first, then move on to things like javascript
from there you can start learning frameworks, but its important to get the basics first
and i suggest starting with flask once you're ready :)
Do I just set AUTH_USER_MODEL = 'User' if I'm using the default user model?
Ah wait, I should probably expose users.profile?
no need to specify an AUTH_USER_MODEL if you're just using the one provided django. if you are extending from a class, such as:
class User(get_user_model()):
you would want that one to be your default user model
and unless you want User and Profile to stay separated, i strongly suggest just extending from the class
also keep inmind, your profile model inherits from User, yet sets a foreign key to User
I want my user to have a variable amount of credits and a verified bool, that's all I need.
So should I create e.g. CustomUser and inherit from User?
if all you want to do is just add a few properties then you should probably extend from the User class.
Maybe I should start with a simpler framework and go back to Django when I have a better understanding of the general way things work
what is the best way to handle the following structure? how can I connect the following ? https://dpaste.org/Sm5c
do you mind share it?
u didnt add the user = User(...)
then commit and save to db
@app.route('/register',methods=['GET','POST'])
def register():
form = Registration()
if form.validate_on_submit():
user = User(Firstname=Form.firstname.data...)
db.session.add(user)
db.session.commit()
return redirect(url_for('home'))
return render_template('register.html', title='Register', form=form)```
I believe this will solve the problem
Hi all, I’m trying to use requests to extract an image from a GET request but I’m not sure how to get the image url, as the request content only returns html data and not the image which is sent separately according to my developer console. The website is https://codegena.com/generator/background-image-generator/ I’d appreciate any help 🙂
Codegena Random Pattern Generator tool is a unique tool that automatically creates amazing background patterns which you can download in any resolution and use for free.
...
AUTH_USER_MODEL by django default is already User. Having a one-to-one field is fine, and you will be able to access any User objects via that field - what seems to be the issue?
Also, "extending" the user model means that you will have one model with all of the User's fields and methods, instead of having a seperate model having a relationship to the User model. It's pretty simple to setup:
https://docs.djangoproject.com/en/3.2/topics/auth/customizing/#django.contrib.auth.models.AbstractUser
Hey guys, does react-admin have a data provider for the Django REST framework?
don't ask to ask, just ask your question :)
so im making a youtube view bot
as my first project
and the problem is that the tabs dont close
so eventually my pc will crash because of 1000000 tabs
I am looking for a good feature-rich JS IDE, should I use JetBrains webstorm or should I use VSCode (with extensions)
@wooden ruin
i use pycharm
pycharm doesn't support js
oh, wait, it actually does, just not as feature rich though
pycharm is very good for JS development
you won't be missing out on any "features"
pycharm pro comes with pre-builds for react etc.
webstorm if you can afford it, but vscode is a good all around editor imo
what libraries are you using?
you can get all jetbrains products for free with a student email acc, if you don't have one you can buy it for $2
uh this is my script
import webbrowser, time
url = input("Enter url: ")
duration = input("Enter duration: ")
for i in range(5):
webbrowser.open_new(url)
time.sleep(int(duration))
@wooden ruin
use something like pyautogui or pykeyboard to close the tab manually. webbrowser doesn't have a method to close the tab yet.
basically, you can't close the tab using the webbrowser module which you are using.
you will need to manually close thme
u can do this by hand or by code
uh i just want the bot to afk
unless i use autoclicker to use them
close them*
il see how that goes
you want to make this as automated as possible, there's a library called pyautogui which you can use to close the window
how do i install pyautogui
which you import
pip install pyautogui
read the documentation of how it works here
cmd is a terminal
small question, as I learn JS, HTML and CSS, should I also build some small (no GUI) python side projects on the way or should I focus fully on JS, HTML and CSS?
yea thats the module for you @native tide , go to the website i sent and go thru how it works
if you want to get into web frameworks written in Python, you will need to learn at least the basics of python and have a good sense of programming
i dont know the coordinates of my mouse lmao
you don't need to right
its at the top right
the x is the highest and most to the right thing on ur screen
right
I know quite a lot about python, or it's just dunning kruger effect, but I at least know the basics and worked on a few complex projects
but it opens a tab
not a browser
oh i can just do it witha closed browser
and it will keep opening browsers and closing them
but my pc is too slow to open the tab fast and it wont go on the site
that's good, and javascript will give you a solid foundation of front-end programming. do you have any web frameworks in mind right now?
i suggest starting with Flask
if that's a case, you might not want to run this program on your pc
thats 100% correct
in fact
you can deploy your program to a cloud service
so you can really afk get views
u dont have to
there are companies that can do this for you
first i need to create the code 🙂
yup
its literally the official documentation of the module
it's not useless, you just have to understand what's going on
Yea it was
how many times did u loop
Uh
or expect to
Forever
how much apart were the intervals
The what
like how often did it open the browser
Like every half second
right so you should probably wait like 10 seconds before doing the next one lol
Rip ram
time.sleep(10)
It's not even starting !!
Yea
Restarting
no
Omg!!!!
Rom?
u have 1 tb of storage
Yea
And no pc
No it literally wont turn off
just turn it off and let the pc cool down
Dont do coding kids
Close your browser
Bruh
Try
well because it needs to close all those tabs first!!
Bruh this is a 10 year old pc
hit the power off
Or try torefresh
just unplug that pc
it didn't
It did
your pc is not damaged
Dw
No
That's what I did last time
And it didnt work
So I took one of the ram sticks out
And it works
Unplug your pc
thats the dumbest thing u can do
just unplug the pc
Yea
nothing bad is gonna happen
Well rip pc
if you refuse to listen then your pc will never get better
You pay for new pc
yes
If this breaks it
ill buy u a 3090
Lol
Ok I did it
good
Plug it again
plug it in again and restart
Don't forget to refresh it
What
Refresh
ok
Ok
🤨
yo wait could i also get some help for web development?
h1 {
font-size: 60px;
}
section h1 {
font-size: 40px;
}
figure-1 {
width:50px;
height:50px
}
so the first chunk of code is my index.html
the second one is the style.css
im having trouble setting the size for the first one
with css
could someone help me out?
I can't find javascript/typescript bundled plugins in pycharm, can anyone help?
yea its the one above this @formal geode
no im trying to get the picture to change size with css
ok
wait were should i fix?
figure-1 {
width:50px;
height:50px
}
there is no ; in height:50px
it should be heigth50px;
so height:50;
*height:50; yeah
k let me try that
k
yea na it didn't change
ok,
well, lets see, HTML or HTML5
yeah
I dont think figure is in HTML5, I have never seen that in common CSS
Try styling the image or whatever with an inside style, aka style="/* whatever*/" inside the tags
alr
incase its not supported in HTML5
you can use <center> tags and css padding-top: 0px;, that's how I usually do it.
or any padding css command
yea but wut if i want to line the photos up side by side?
wait do i just determine it with
top:0x;
right:0x;
yes
k thx man
any way you need it, its there
@digital mango WAIT
another way to fix your problem is doing
.figure-1 {
width:50px;
height:50px
}
insted of
*instead
figure-1 {
width:50px;
height:50px
}
But I hope you got it figured out
oh thx man
your welcome
this is my first time with js and I am really confused, I edit the js code in pycharm, but what next, how do I run it?
I can't find "open in browser" option
and no, I don't use HTML/CSS, I am just learning the basics of JS first
Hey guys, I'm new to development but I know enough to piece together stuff. I've been playing with writing my own REST api with flask, and was wondering: Is there some good resource or guide explaining the basic "best practise" way to set up a fully functional website, which details kind of a basic structure? Like, is it all just separate containers running nginx and flask (or nodejs or whatever), and how would you structure the back end of a basic web site/service from scratch?
You mean, best way to have wiki for API?
no, more in terms of, let's say I want to build my whole back end from scratch. Set up a server, write the API endpoints, run webservers, etc.. Is there somewhere you learn how to build that environment in the most up to date way?
basic security no-no's, what kind of services that might be separated into different containers so if one goes down not everything breaks etc
or is it just service providers all have their own infrastructure, or builds one custom for a client?
Um, you are looking to read several books at least:
I know, there is book for django that cover most of your needs. Set up server, write api end points, run web servers, basic secirity and etc
You are also mentioned microservice architecture, it is separated book to read about this
If one goes down, not everything breaks. You are looking for a devops stuff now, like kubernet
Ok I'll see what I can find. I know about kubernetes though i've never set it up.
Three separated topics basically
I would recommend conncentrating on first topic
Reading books about django from beginner to professional level
basically, I got into python to write a discord bot for my csgo surf server, so it would fetch server records and user info from the sql server. I wanted to serve them to my website and then I got into flask. Wrote a separate API so that the bot and my website could fetch the data. But I just know I'm not structuring things the "right" way, and want to learn more.
if i wanted to scale it up, have a login page and maybe some web apps, I would have to consider a basic setup before clustering with kubernetes
Do you have already existing mysql database
Which you have access for
Already filled with data and working in some service
yeah I have a VPS running ubuntu, with a stack with apache mariadb and all that jazz for the main site and flask serving the sql data
that not really the point, I just want I flowchart of sorts i guess. some pointers into structuring a full back end for something that could run many different web apps
maybe not the right place to ask
May be, you are looking for docker compose
It helps packing with easy into multiple containers
Makes your whole infrastructure, as one small script to build everything
no i mean the architecture, never mind what i use for clustering or load balancing
just, what is the common setup when running a basic back end serving both html and webservices and api endpoints
i think i need to think about this and word it better
who cover?
Authors of framework books explain common good setups for the chosen framework
this is kind of hard to learn
in isolation
usually you get that kind of knowledge/experience
from working somewhere
but feel free to ask specific questions
I'll answer whatever I can
yeah suspected that. I've worked in IT but never with development and certainly not infra on that level
i dunno, I just found this guide to flask environment that was kind of illuminating, it breaks down the basics of how in a flask framework you have to set up all the parts yourselves whereas in django you have kind of a basic setup to work with, database and all..
i guess I just cant shake the feeling that some where some one drew a box diagram with a basic structure of all the different containers and then I could figure out how to construct my own site in a way where i wouldn't over look a huge security flaw or a stupid solution 😛
That is why I like Django.
We have even command to check for stupidity in security settings there.
python manage.py check --deploy
😄
Plus books are great, explaining common bad solutions for django
and that's probably what i SHOULD be spending my time with but i'm just curious i guess
i like the idea of building everything from scratch
it gives me so much insight when i need to troubleshoot IRL
It is great for first experience
You appreciate more, framework with everything inbuilt
After that
I started with flask/quart microframeworks and only after that jumped to rails from the box django
Flask gives more freedom. That what should be learned first I guess
To try different solutions on your own
Before jumping to think in box solutions
Thanks man. A broad qeastion: everyone seem to talk about running nginx and flask or or other stuff instead of the old apache/php, stuff. Is it normal to serve everything from small light weight webservers in containers in loadbalanced clusters etc? Would a huge website like twitter or fb use just a huge farm of containers running nginx or something like that?
How much experience fo you have with html, css and JS?
yo
Can someone help me I just added a user model and this happend
models.py ```from django.db import models
from .utils import get_manga_info
from django.contrib.auth.models import AbstractUser
class User(AbstractUser):
pass
class UserReader(models.Model):
user = models.OneToOneField(User, on_delete=models.CASCADE)
# def __str__(self):
# return self.user.username
class MangaTracker(models.Model):
url = models.URLField(unique=True)
title = models.SlugField(max_length=255, blank=True)
img = models.URLField(max_length=255, blank=True)
description = models.TextField(blank=True)
latest_chapter = models.FloatField(blank=True)
latest_chapter_link = models.URLField(blank=True)
latest_upload = models.SlugField(max_length=255, blank=True)
latest_views = models.IntegerField(blank=True)
reader = models.ForeignKey(UserReader, on_delete=models.CASCADE)
def __str__(self):
return self.title
def save(self, *args, **kwargs):
title, description, img, latest_chapter, latest_chapter_link, latest_upload, latest_views = get_manga_info(self.url)
self.title = title
self.description = description
self.img = img
self.latest_chapter = latest_chapter
self.latest_chapter_link = latest_chapter_link
self.latest_views = latest_views
self.latest_upload = latest_upload
self.latest_views = latest_views
super().save(*args, **kwargs)
i feel like the problem here is how I made migrations and migrated
then just delete all the migrations folder and the db file and try to migrate it again or do you have a non-local db?
You can run Flask with Apache btw, the cheapest option for hosting and serving your flask app
hey guys , need help with flask ... so my problem is when I link css with html and then if I use in my template url_for(‘static’ , filename=‘style.css’) for some reason it doesnt work , any suggestion?
i am making a login page
i want to store the data entered by the user
like it should come to me
how can i do that
hm
that's actually
a few things that are related but distinct
so
first, horizontal scalability is important
second, full VMs are often too heavyweight
that leads to stateless, and therefore fungible, containers that can be easily replicated
which is why you see container orchestrators (most common example: k8s)
and, yes, load balancing plays into that
Flask vs PHP is more a choice of backend technology
same for nginx and Apache with regard to server choice
though they can be combined
that said, the trend nowadays is towards IaaS/PaaS
where all these things are managed for you
what do you mean it should come to you? if it is to store the data on your pc then you should create a database
apperently datetime.datetime is not serializable
found funny solution to work around
def serialize(date):
return repr(date).replace('datetime.datetime(', '').replace(')', '')
def deserialize(json_value):
return datetime.datetime(
*[int(item) for item in json_value.split(",")])
literally one string solutions ;b
mm, Django REST API to work with user database
after user login I create token? to which repeated access can be used
the token I generate from Dictionary with several values (ID to database, user email, and few other parameters) and encode with SHA256
I wished to have also datetime.datetime stored in token
huh.
looks good
I would have to encode/decode to SHA256 with few additional strings then
but I guess it should be better may be
PyJWT jsonified and encoded for me
sounds good 👌 so is it necessary to encode email and username as well?
isnt enough with password?
mm... only password is encoded in order to be stored into database
this encoding I use to generate tokens, which are just temporal things for cookies I guess
email is encoded into token there as additional layer to verify token after decoding
Can you install a package to a live server while its running?
pip installing something to the venv
but the only way to intall a package is to activate the venv ( which I'm assuming is already running ) wouldn't that interupt it?
to be honest, I don't understand, why would you wish to install package during runing server
what's the point?
dark have you been using flask or started with django?
you will not be able to run tests
because I am adding a contact form page
used before Flask, currently working with Django
and i dont want to bring the sevrer down
ive done it locally
it works
just need to upload the files to the production server but never have done it with a file that needs a package the server doesnt have
so should I use sessions or just leave it , or depends on the website?
I know nothing about your project
ye just asking whats your opinion ..
my answer: not enough information to answer
usually sessions exist in some form or another anyway
but I have no idea what you are doing there, so not sure if you need
lets say I just started with flask a month ago , dont need to go in depth just wanted to know something about sessions
I know this is not the Q. channel but it happened a lot that noone answered me so I tried to ask you
if you want your user being travelling between pages with memorized login state
you should use sessions
if all your users are guests and authentication is not needed or any other information about user between pages switching, you can skip sessions
alright, appreciate it thanks 🙏 so basically for a website where is no user information stored it is useless
in 98% cases, yes
but sometimes websites secretly autologin users to temporal user accounts
in this case it would be still needed
okay thank you 😎
all right, all is left to find encoding decoding algorithm which works in both ways
HS256
How to do that
ISO format?
can it be deserialized back?
serialized = repr(date).replace('datetime.datetime(', '').replace(')', '')
deserialized = datetime.datetime(*[int(item) for item in serialized.split(",")])
I currently do in this way)
WTF
no
>>> a = datetime.datetime.utcnow()
>>> print(a)
2021-04-30 10:45:00.660008
>>> b = a.isoformat()
>>> c = dateutil.parser.isoparse(b)
>>> print(c)
2021-04-30 10:45:00.660008
>>>
thanks, it works
you can use datetime.datetime.fromisoformat
huh, even better
this is p mad LOL ngl
but it’s okay we’ve all been there
ca someone tell me how to hide label text after 2 seconds in asp.net webforms
Im just a newbie
difference between react and vue? I've been looking into both recently
how
Hi guys, I have a Rails app where I use devise as authentication solution, I would like to create a simple python Flask API and authenticate the API with the preexisting user table, what would be the approach, any advise?
Wdym by "devise as authentication solution"?
devise is ruby gem for users authentication
Well, i'm not familiar with it 🙂
👍
I mean how can i possibly help you if you're using some ruby specific library 😉
do y'all think it's better to use node.js for back end or is it better to use python?
or should I use both?
Python for back, Node.js for front
It depends on what you're more comfortable with
I like both
How would you use node.js for front? 😅
React ;b
js is not node.js
hmm, really? I thought it uses node
well, flask can handle requests asynchronously, right?
if not, I'll have to use node.js
It can, but it's not async
a bit of trouble it has with it
better to choose some Async framework
Sanic or something
Closest analog to Flask is Quart
how does netflix, for example, use flask to handle requests
It can handle concurrent requests but it doesn't use asyncio
so I won't have to make my program asynchronous? flask will handle it for me? good
I would recommend fastapi over flask though
is it as easy as flask?
It's similar
I want something that has similar syntax and structure to vanilla python, not something that has its own syntax like django
btw, FastAPI is rails out of the box type?
More like flask with extra features
urgh. I like rails
You still have to choose and orm if you want to use one 🤔
I'll prefer to override rails to suit me ;b
I'm not familiar with rails
I know but it's awful for api's
wait, what's the difference between web applications and backend applications?
a simple google search says node.js is better for web applications, where python is better for backend applications
huh
looks hard to understand
js isn't node 😅
What's this
tbh, no idea
There's like just unrelated columns really
yeah
give us your first link
we have different ones
due to different advertisement settings
What is Node.js? Node.js is a server-side platform built on Google Chrome's JavaScript Engine. It uses a non-blocking, event-driven I/O model. It allows developers to create data-intensive real-time a
for our google account/ip address
just use an adblocker and VPN xd
I guess I am not familiar enough with Node.js
to say anything
I only worked closely with python
What you would use with node for api though?
I don't know, I am still learning it
the biggest thing I did there, I was forced quickly to find how to deploy React app to production ;b
What is react used for?
Frontend applications
basically for GUI of web site
Ok
It depends
LOL I understand, what about authenticating users on flask api with the preexisting users table?
so ye, I like both python and node, but I am still wondering if it's a good idea to use both in back end
Depends on type of authentication 😅
email and password
And what you want to return really?
Plus why would you handle it in separate app?
When you have rails app
The return would be user's company information like sales orders status, items and debts, very simple; I would like to have separate because I already have an internal flask API to make some data analysis (in this case I dont use authentication because it is only accessible internally)
I think you can use sqlalchemy as an orm and fetch data you need from your tables 🤔
hy can u gimme a whole code for webpage
At BootstrapMade, we create beautiful website templates and bootstrap themes using Bootstrap, the most popular HTML, CSS and JavaScript framework.
Hello, I was in #help-corn and they said my question should fit more over here, if anyone can help me 😮
hey, is it possible to make a wtforms custom validator that can receive 2 arguments?
Hey guys I'm building a webapp with flask and I want to do kind of like a catalogue but my FE skills are terrible... any recommendations of what kind of css framework to use to hide that fact???
Tailwindcss makes it pretty easy
very nice framework to use
or Bootstrap templates
Thanks, I'm not planning to use nodejs in my project so I guess I'll have to go for the classic bootstrap
https://tailwindcss.com/docs/installation#using-tailwind-via-cdn they don't recommend it, just for demos
unless you really want to customise it, its fine
but yes
you will get better build sizes using the CLI
hi it's a general question i'm using javascript (even though its a python discord but any help will be appreciated.
So this is a very simple login form
I'm using php to submit the form data and it takes the user to the new page
let e_user = "<?php echo $_GET["username"] ?>";
let e_pass = "<?php echo $_GET["password"] ?>";
</script>```
This is what i'm using to get the data in JS varaibles.
It is basically a login to an admin portal.
but isn't tailwind like css rules but classes tho? wouldn't you be building components from scratch with it?
It will have only 1 password and 1 username. I want it to check if the entered password matches the password i want to set for it. What is a safe way to do it ?
I can just use conditionals to check for-example if e_user == "admin101" and e_pass == "somepassword" but that will be in the source file.
you can store the details in a database
remember to always store the passwords as hashes for security reasons
I don't know how to use node.js in web development , i just use simple js or php. Is there a place to learn it ?
@thorn igloo yes, tailwind seems to look for classes in the markup to add some styles but some of them uses javascript that's why the nodejs 😦
I mean, to connect to mysql ill need the mysql.js right
php is a backend language no? I think you can connect a database to it. it's not a nodejs specific thing
hmm i'll check
oh thanks found this https://www.w3schools.com/php/php_mysql_intro.asp
*any *language can connect to a DB tho
can anyone tell me how to clear a sqlalchemy database from tables?
looking for an answer but nowhere can find
Is it ok to set dashboard as home page for clinic web?
can someone tell me why my website doesn't open when i send it to other people
but works when i open it
ping if reply
do you want to drop all tables?
Using Python, what's the easiest way to implement website search that searches through HTML and markdown files?
sounds like you're probably hosting it locally
what do you mean by search through html and markdown?
I'm making search, and I need it to find whatever the person is searching for. And I'm searching through html and markdown files for that text
Did you deploy the website?
maybe beautifulSoup might help you but I'm not sure if it supports markdown
Thank you!
make sense, prob 127.0.0.1 or localhost
i probably am(i'm new to flask and python)
how does one......
What did you make the website with?
And that's the url in the search bar when you're on the website?
wdym?
it was something like this http
o
so u can only access with ur computer
i'm trying to run this on python only
guys, is python excellent for back-end web dev (with intent of linking that backend to android or ios apps), or is it better I consider .net or java or nodejs or the like? I'm new to all these languages anyways ;p
idk i'm new to this
ik, so use the platform to host it
pls explain
Host, run, and code Python in the cloud: PythonAnywhere
u register an account and put ur code into it
Want to deploy your Flask app on the web? Try using Python Anywhere. I demonstrate its use in this video.
https://help.pythonanywhere.com/pages/environment-variables-for-web-apps/
https://www.pythonanywhere.com/
Join my free course on the basics of Flask-SQLAlchemy: https://prettyprinted.com/flasksql
⭐ Kite is a free AI-powered coding assi...
do y'all think I should learn node.js or js first? I don't know much about HTML/CSS and I am not interested in them for now, but I won't using JS for server-side stuff that much either
are the concepts I learn in node.js all usable to js (excluding server-side concepts of course)?
Honestly, is js better than python for web development?
well it depends, use what ever language you prefer on the backend
on the frontend you cant use Python (no brython is not a option) so you kinda gotta go with JS or TS
Hi does some ond usd pythonanyehere
I want to test my scriot from python on there
To see how it works
guys i got a question. Does anyone know if i can "wait" for a respose (certain text or popup) in python selenium?
like if i want to signup in a website and i have multiple emails and i want to try them one after another
node.js is awesome and has frameworks for both front-end and back-end. (vuejs > react btw). however, it's best that you have a solid understanding of HTML, CSS, and basic JS before moving on to node.js. once you have a solid understanding, i'd say the choice is up to you whether to start learning front end or backend. if you want to use python, use it in the backend (brython sucks). there are tons of node backend frameworks such as express, fastify, nestjs, nextjs, and nuxtjs
hello can someone help me real quick. I have to code on a local server with some python. (make a game with python and show it on a webpage) how can I do that? I have already made a server but I don't know how I could show the code. Do I have to make a html file and use a script node to implement the code?
u can choose free version
you can just think of Node as something that lets you use JS as a backend language
historically, JS only ran in the browser.
so, more or less, yes.
can webscaping questions go here? specifically why can't I find an element by xpath in selenium when I'm looking right at it? lol
either your xpath is wrong
or the element hasn't loaded yet
well, those are the two most common causes
Is there a way I can redistribute pods once a new node has been added? I have a node pool of lets say X nodes, and I have made a custom scaler that adds/removes nodes based on certain conditions, but I would also like the pods to be rearranged when a new node is added
yeah. I thought the element hasn't loaded might be the cause, because that is what happened to me before, but I navigated to the page through the terminal, so I can see it has loaded before using
floodZone = driver.find_element_by_xpath("//*[@id='fz']")
wait sorry I don't understand
can you see the element in the actual Selenium driver window?
yeah
yes
ok, right click inspect shows it, which is where I normally steal the xpath. but view page source shows much less.
that's Weird
"view source" shows you what the server sent. "Inspector" shows you what it looks like "now" (i.e. after client-side Javascript has modified it)
That's what I thought, which is why I need to use Selenium vice BeautifulSoup, based on my rudimentary understanding of the two lol
The website I'm looking at is
https://www.mymanatee.org/departments/building___development_services/floodplain_management/floodzone/flood_zone_information_tool ```
and you can use the generic address they give you, 1112 Manatee Ave W, to search. I'm trying to get the flood zone information.
yes but
if you're accessing it through the driver
it should show the rendered HTML
You might have better luck calling the API that feeds that page: https://www.mymanatee.org/gisbads/rest/services/flood/flood/MapServer/0/query?f=json&where=((PRIMARY_ADDRESS LIKE UPPER ('1112%25') OR PRIMARY_ADDRESS LIKE UPPER ('%251112ND%25'))%20AND%20PRIMARY_ADDRESS%20LIKE%20UPPER(%27%25MANATEE%20AVE%20W%25%27))&outfields=PARCEL_ID%2C%20PRIMARY_ADDRESS%2CPROP_CITYNAME%2C%20HASHID&returnGeometry=false&returnTrueCurves=false&returnIdsOnly=false&returnCountOnly=false&returnZ=false&returnM=false&returnDistinctValues=false&returnExtentsOnly=false&orderByFields=PRIMARY_ADDRESS
To find that, open Developer Tools, click on "Network" then do your search. You'll see that request in the list.
ok, I see the information I want, I just need to figure out how to get it.
awesome - have fun!
lol thanks. Any reason why Selenium can't access this?
I don't know enough Selenium to answer that
If you want HTML instead of JSON, you can (apparently) change "f=json" to "f=html" in that query string and get an HTML form. Submit the form and the response has the same data, but in HTML.
Maybe that would be a more comfortable starting point?
Maybe. API's is something I haven't tried to interact with yet. I do have the Arc API reference up, and can start playing with that. We'll see if I end up in jail or not lol.
With all the references they have published, I think they're happy to have you use it, but yeah - check to see if they have rules and follow those 🙂
good luck!
Thanks again.
So I went back a bit in the elements and found:
<iframe src="https://gis-publicportal.s3-us-gov-west-1.amazonaws.com/floodzone.html" width="100%" height="1600px" title="Resident Information Tool address lookup" frameborder="0"></iframe>
I followed that URL and was able to interact with it with Selenium and pull the data I needed.
Sweet!
Is front-end dev in python as powerful as other techs like html+css+js or frameworks like ReactJS?
well
that's kind of a weird question because
React is still JS
and
well
there are two ways to use Python in the frontend, basically
one is Brython (transpiles to JS)
I can't remember the name of the other one but it's a Python interpreter running in JS, basically
both are p immature
what about using Jinja stuff with Ajax/JQuery stuff?
will it be a reasonable equivalent?
anyone familiar with gunicorn and memory management? I'm curious why when when a gunicorn with sync workers w/ gthreads respond to requests, they make threads that don't seem to ever get recycled until another request comes in.
is this the intended effect? I'd imagine the threads would just die immediately after they're used to free memory.
I am not familiar with it enough
But I know that deleting and creating threads is heavy task, that made async solutions more popular in comparison to threading
it is possible that it is intended effect in order to cut time for those tasks
also, heavy applications can be reaallly long time initialized, it can be also intended in order to cut down this time as well
that is interesting @inland oak . That does sound like it makes some sense. I had a server with 9 workers and 25 threads on a 4core/16gb ram machine and it was chewed up quick
i ended up just forcing processes to reset after "x" amount of requests
in some frameworks, like Quart it is possible to rewrite a little bit their framework code, to limit amount of PoolThread workers to suit yourself better
as far as I know, standard value at least in asyncio 5*amount of core processsors for worker limit
it is possible to regular this value in Quart at least, with a little bit diving into their code and rewriting
aaaaah
it was actually focused on Django and Flask
I meant if it was worth learning them or if should I learn other tech like a JS framework for web development
from concurrent.futures import ThreadPoolExecutor
import multiprocessing
pool = ThreadPoolExecutor(max_workers=multiprocessing.cpu_count() * 5)
in quart framework utils.py file for run_sync function
yea gunicorn allows a user to change the workers as well
they recommended 2*cpu + 1
sounds reasonable
yea, the thread portion is the one i had to experiment with i suppose
some simple DDOS attack makes possible to overload server with enough of amount of new created threads for requests
having them limited to the level your server can process in a queue is a good idea
so im still a bit of a noob with threads, but if I'm running "top" and a process is showing 4 threads, is that really 4 OS threads although gunicorn is using gthreads?. Or is it 4 threads where each thread is running gthread on top of it
well
depends on what you want to do.
yes
huh why
mostly because the concept of such as "virt" and "res" is still a bit foreign to me
and how that ties in with threads
like if I see a process with 4 threads, and each one shows 1.0% MEM usage, I'm assuming that's 1.0% of the process, or is it 1.0% x 4 within the process?
hm
since threads share memory with a process?
I actually don't know the answer to that
rather outside my sphere of expertise
but
I would assume that it's the former???
I have no idea 🥴
Perhaps
regular thread is created within some function, completes the task and is usually finished or something
Flask is meant to be scaled with creating your multiple applications running at the same time
I assume Gunicorn makes exactly that
each Gunicorn thread contains independent running full copy of your application
uh
from what I understand
Gunicorn uses green threads
like async/await so process-managed threads except it preempts them
but
each OS thread
can have its own green threads
yea, that's my understanding.
gunicorn forks a process, and say we have 4 workers, thats
(main process) -> 4 child processes -> x threads
it also has the option for "preloading" flask into the main process
or if you don't preload, all 4 processes (workers) will have a copy of the app
sounds like React framework
javascrypt, preferably used typescript
thaaanks @inland oak
any1 know how i can access 'name'
can django run python code while the website is running, or does it run all the code at the beginning?
the html looks like this
django runs in a python environment, so yes, you can do other python related stuff while it's running
So polling a database is possible, right?
yes
Do i need a host for making my website "online" if i made it with django?
yes
anyone here who knows a bit about wtforms?
what's your issue? i've used them before
im trying to make a custom validator with 2 inputs, but i cant find anything in the documentation to make a validator with 2 inputs
what do you mean by two inputs?
are these coming from the form or externally?
it only works with 1 input so: def validate_subreddit(self, subreddit):
both form the form
atleast i think so i tried to use hiddenfield for userid\
from one form, from one input?
its like this:
class SubredditForm(FlaskForm):
userid = HiddenField()
subreddit = StringField('Subreddit', validators=[DataRequired()])
ok, i have a question, what's the userid field for? given that it's hidden
i need to do a query and i need the userid for it
you want to query inside a validator?
yeah, but i need 2 things in the query the userid and the subreddit
ok, uhm, have you tried giving the function itself two arguments?
the validator function
I have the following div:
<div id="texts"></div>
And it outputs the following image:
Is there a way for me to get each of those images & texts into a seperate box?
userid needs to be userid.data btw
yes, so why are you passing userid instead of userid.data?
in the chooseuser function
that was a mistake, but it still doesnt work, because the validator inputs this: validate_subreddit(subreddit) instead of validate_subreddit(subreddit, userid)
bro, you can do this: subreddit = StringField('subreddit', validators=[your_validator(userid = userid)]
that's the idea, in theory it should
also, how are you defining your validators? in the form or separately?
ok, if it's in the class form should'nt you be able to like access all the fields in there?
you dont need to specify it like that if it's a class method, wait, let me show you what i'm talking about
okay
alright
hi, i really need help with building a chat app in django. i built already the site now i need to make the chat with socket or django channels. can some one help me with it?
im very new to django so it is very difficult for me to do this app
(i tried lots of tutorials but its hard for me to understand when i cant ask questions)
what is more used in django, function or class based views?
class based views
thanks
depends on the developer. there's no difference between them. I prefer functional
can some one help me with it please?
you should probably start with the basics of Django before really jumping to the more advanced stuff
i have this page when i enter information in it then if i go back using browser and then come back to same page again all the fields are empty
how do i save them so if i close the browser of come back to page all the entered inforamtion comes auto
For what sql is used?
SQL is a type of database, it's used for example in web development to manage users.
Ok
Thanks
So if i want to store data entered by a user i have to create a database for the website
Generally, yes, but there are lots of different options
SQL is a query language. It's used for manipulating data in relational databases.
sqlalchemy
You don't have to create a database database. For example, you could have a directory with files, where each file has the user ID as its name and store some JSON data about the user. It's a database, even if a primitive one.
If you want to make a sightly more complicated database, you should check out SQLite. It's a database management system that uses a single file for storage. There's a tutorial by Corey Schafer: https://www.youtube.com/watch?v=pd-0G0MigUA
Django channels is the option. What are you stuck on?
django channels is the way to go. daphne is officially supported by django and makes deploying semi-easy
do know that channels uses redis
so if you want to scale, use redis
if you are just deploying for fun, you can stick with the in memory channel layer
Ey up
Imo, React is only good for SPAs. If you're a react person and want to make multi-page, use Next.
i like vue router for things like SPA's
React isn't bad
I like it a lot but i dont make complicated stuff
they are also a good learning opportunity, personally i prefer vue over react but they each have their advantages and drawbacks
is it better to deploy your react/vue app standalone using something like express, or deploy it directly to your api?
State management is convoluted using contexts. Global state is iffy at best. It still uses a vdom which is slower than not using it, and there’s enough evidence that it isn’t a good solution anymore. It’s also not compiled into js. It’s just transpiled thanks to Babel and still carries an overhead that isn’t necessary. But for all the shit I give react - it’s popular and well tooled. So it’s not necessarily the devils butthole, but I just think there’s better alternatives if you don’t mind the lack of ecosystem.
Hello
I kinda want to learn Vue
Since I've seen some Vue code, and it seems to be much more like HTML than React is.
i like vue because each component has its own html, css, js, and vuex/vue router is straighforward
well, vue has vuex, which is similarly a giant global variable
ts support is horrible tho for vue
Honestly imma sound like a shill, but try Svelte.
Next ain't bad.
Or elm.
Honestly, React is popular, but it's not really the best
svelte seems to have great TS support
I think it supports ts by default. As a base.
They encourage it afaik.
nestjs uses ts by default right?
svelte also has single-file components with scoped CSS, just like vue
^^^^
nodejs has so much support its crazy
JS has nothing equivalent to something as good as Django from what I've seen
That’s why I love it. It’s fast, it’s got a great concept of state, great way of handling performance and most of all it doesn’t relegate stuff to virtual Dom and instead just neatly compiles down to JS
django is a batteries included kinda framework, so if you don't need the features that django has you have the option of going for something lighter like flask
I just wish there was a JS version of Django.
like the django session and authentication middleware, that fact that it's all taken care of for you, is crazy
@manic frost can i dm u abt smthn pls
why?
Django is absolutely amazing
I remember the days long gone when I used turbogears. Anyone remember that??
The amount of work put into it is phenomenal
that guy who was in general talking about using tor or whatever dm'd me saying he was 12 which is against tos
You should contact @hexed spoke
ok thank you
Is svelte worth learning?
totally
It has a great interactive tutorial:
https://svelte.dev/tutorial/basics
although it gives too much attention to animations for whatever reason, so you can skip that if you want.
wbt graphql?
i've also heard people say that passport sucks and all this but is it good for an authentication library?
Thank you!
What’s your use case for it tho? Graph Ql is great if you provide api as a service, but if you run the front end as well as the backend, then you just tailor your api to give your front end what it wants. Why use graphql and add the overhead when you’re the one designing both sides.
Hello people, I'm currently working on a project developing a website and have some basic questions about that topic/would like to get some general advice on further steps. I hope that this is something you can ask about on this server 🙏🏽
Shoot
What questions?
so first of all, I work with a group of people who have no experience in programming whatsoever and I tasked them to write a front end html script for our website. After that a web developer friend of mine told me, that if they only write in html they won't be able to acces data from the backend script/data base. I did some research and saw, that in django you can use {{}} to do some simple coding in the html files, but I was wondering if that is something smart to do or that you usually would write functions elsewhere and add them to the html file. I myself am a beginner at coding but i have to manage a group of non programmers rn.
At the moment i'm learning on how to connect the db to the website, which seems fairly simple
Well.. from what I know about Django is that it will generate html based on templates. Which is the {{}} syntax you mention. So really it’s - Server>template > html> front end. But all interactivity is done via JavaScript or at worst - forms via submit\post.
What is the goal there? If you can share that
