#web-development
2 messages · Page 155 of 1
can you elaborate?
I don't really understand
maybe you can give an example
sure!
let's say that I install Flask module, import it, create some function with a route decorator to some address and then initialise Flask's server
now, If I open the local address where the server is being hosted, I see the output of the function on-screen (let's say, for the sake of simplicity, that It is a print() statement)
so my doubt is, how does the whole process of relating the script where I wrote the function's output with the webpage display of that output?
when you say "on-screen"
you mean
in the browser?
yeah
that shouldn't be happening
you mean like you have:
from flask import Flask
app = Flask(__name__)
@app.route('/')
def get():
print("printed string")
return "returned string"
you see "printed string" in your browser window?
ah
yeah It's a really simple doubt itself I guess
then that's not a print statement, right
that is what is being returned
from the function
so basically
yep you're right, that was a misconception by my side
a web framework is just a bunch of code
that maps routes (URLs) to Python functions
those Python functions do whatever and return some data
then the web framework takes that data
and processes it in a way that web browsers will understand
and finally returns it to the web browser requesting it
so the cycle goes something like this
user script -> web framework -> translation of the data for web browser compatibility -> web browser display?
- web browser visits a page with a given URL (sends a "request")
- the web framework looks in its data store for the Python function that will handle that URL
- the web framework calls that function
- that function does stuff and returns something
- the web framework processes that "something"
- the web framework sends the processed something back to the browser (the "response")
you can look up the request-response cycle
oh cool, imma save all this
thank you so much 😄
there are things like content negotiation
caching
etc.
but this is the gist of it
yeah but for starters this is nice
nah I'm from Spain hahaha
why is that?
because usually "doubt" is used to mean "suspect" (like "I doubt your intentions")
the way you used it was more to mean "question", which is very common among people who come from India
like "I have a doubt" instead of "I have a question"
just an interesting point, nothing big
yeah, in spanish 'question' is more like directly asking something without any real interest and I guess I related 'doubt' to the spanish equivalent of asking something with interest, 'duda'
😛
next time I'll just use "inevitable concern about the topic hereby discussed" lmao that'll be funny asf
ah okay LOL
yup no worries I understood you perfectly
it is unfortunate that English has only one word for this kind of thing 🥴
yeah :s, well, imma go take a look at that backend mistery, see ya
yup, atb! 👋
hey is any1 free rn??
You need help?
done by myself tq for replying love u
yw 🙂
btw can u give me some tips
i dont even know whats your problem
what is it about?
i want tips to learn Django fast
oh ok then
and mistakes what ppl do while learning Django
give all ur exp
to me of Django
plz
ok
ik flask btw
good
what i do?
tell me whats your problem then ill help you with it
i cant give all of my exp
ok so i face problem while starting localhost server
oh
why bro
its kinda hard you want give all of your exp
i dont know what to say really. just tell whats wrong i can handle it
in short i want to know about how and which problems did all face and how to come up ig i dont want to lose but it seems vast and hard
then flask
why its too hard to open 127.0.0.8000 server in django
no its not that hard
use terminal and stuff
you mean 127.0.0.1:8000 right?
commands make django even eazier
yes
u know flask??
its simple run
and we can debug errors ez too
but in django error comes in termanil
i forgot and trying not to remember
thats annoyhing
lol why ;P
no you can see errors even on your browser
nvm
you know i really recommand docs
oh any good reason
the best videos outhere is for corey and i think even those videos are a bit complicated for beginners. and yeah something is a bit hard when you want to move to django
and if you a beginner and you have any problem with running the server i can guide you to there
for web dev
i highly recommend some of corey's videos
Welcome to my Channel. This channel is focused on creating tutorials and walkthroughs for software developers, programmers, and engineers. We cover topics for all different skill levels, so whether you are a beginner or have many years of experience, this channel will have something for you.
We've already released a wide variety of videos on to...
he covers pretty much everything you'll need to get started with web dev and python in general
and also 2 scoops of django 3.x, really good for best practices
anyone going to djangocon?
oh that gotta be cool
does anyone know if DRF custom field validators just point to the function object?
validators=[equity_is_valid]
what happens in the background? Is it something like functools.partial(equity_is_valid, *args_here)?
Help with fixing this
Just a simple question😅 , how can you add token inside html href?
hello. i want to learn django i am trying to add some back end functionality to a website i am making but i dont know where to start. I dont really know what django does or how it works so is there a good ressource to learn it
The official Django tutorial is really good
ok now i started the tutorial but i dont understand why u have to create a project directly from the command line
like dont u just create a file called like site.py and thats that
and then you import django
It's easier to make it from the command line, since Django is pretty complicated and it gives you the starter files easily
Sadly, Django isn't that easy
yeah it seems rlly hard
like how long is it gonna take me to learn the basics of it
because i already have the css and html done
but if i am gonna create project i do i incorporate it with my html and css
do i put it in the same folder as where my css and html is
Hi guys, I'm new here. I'm trying to create a website with Flask using HTML, CSS and JS. I need help creating a sort of drag and drop area where you can drop one word at the time to compose a sentence (the area becomes one "place" longer every time a word is added). Anyone has some ideas?
I so that drag and drop on HTML is not adviced and I did not find anything simple with JS.
So kinda like advanced version of wordtune?
does that come with the declaration when you create project in command line
Maybe? I forget. But the guide walks you through it
it should be if __name__ == "__main__":
ok thanks
no problem
what are backends in django and how to use them?
django is a backend web framework that you use to build server-side web applications
there are libraries that you can use with django that come with their own features, but they are not backends, simply libaries
popular django libraries include drf and channels
oh wait... i worded it incorrectly
i wanted to use a django builtin for rate limits
and i don't really get how to use it
and what it is really
which is best django or flask ?
yeah.. but for webD which is most preferred ?
i don't really know
flask is simple and can be used for quick projects
but is limited when more complex features are needed
there's no true answer to that afaik. django and flask have their own usage. flask is usually optimized for lighter apps and django for heavier applications
it just depends on your preferences
okay..
what kind of token and for what porpuse bc idk why you would need it inside an html <a> tag by the href attribute.
For some reason Django isn't Inheriting my base file
It inherits but fails to inherit load static
wrong question
big part of SWE is understanding tradeoffs.
when you’re talking about such high level design choices there’s rarely a single right answer
and that’s also a false premise
what about other frameworks?
Quart, Sanic, FastAPI
yeah for some weird reasons you cant inherit template tags so for each file you need static you gotta load static on top even tho it inherits from a file where its already loaded
Pyramid?
Flask jwt is for the token, and I'm trying to use html href to open another route that has been secure with token
with flask, should I use
<link rel="stylesheet" href="{{ url_for('static', filename='css/main.css') }}">
or should I use
<link rel="stylesheet" href="static/css/main.css">
both work btw
Anyone familiar with Vue? I have sections of a page that I built independently and wondering if it's going to be a problem if I have one Vue instance per section (multiple for a page).
No data is shared between sections.
are you talking about multiple vue apps per page?
Components?
that might be hard to manage, i suggest just using components or even routes if it fits your need
Yeah, I am talking about multiple Vue apps, i.e.:
var page = new Vue( ...
I'm also using components, but only for markup that repeats itself multiple times in any given section.
I plan on using routes in the future, but all the sections are going to be under the same url (same page), so not sure routes is appropriate.
Thanks, though, and please let me know if you have any more suggestions.
How to ensure the dragged element in selenium is** appended **to parent python ?
i meant the drag and drop in selenium
Hey, I've been wondering about using a JS framework in this manner and was wondering if you're fine with me DM-ing you to ask some questions? 🙂
You should probably ask here
More people can help that way
can someone look into this question I just posted to SO? It's better formatted there than it would be here
Oh, don't really need any help per se. I was just interested about the process, that's all.
I was curious about how the app is structured. Do you have Vue's library installed or are you using the CDN? Do you have individual JS files on each page?
How about building and minification of the Vue code?
You can pass the list of authors down as a variable to the template
@app.route('/')
def index():
authors = ['a', 'b', 'c']
return render_template('form.html', authors_to_render=authors)
<select name="...">
{% for author in authors_to_render %}
<option value="{{ author }}">{{ author }}</option>
{% endfor %}
</select>
Thanks this will help
Hi everyone, any one interested in working on a full stack side project with me, am mostly skilled on the backend need someone to help on the front end with React. I already have the project UI designs. Please DM me
what you working on?
I am in Django and
accepting some API request
what would be the most cultural way
to get the route of my server
https://domain.com
as not cultural, I could extract from request.get_raw_uri()
"/".join(request.get_raw_uri().split('/')[:3])
but it looks slightly as messy solution
I've messed with Vue and React before, so I can try to explain
Usually for a production app, or even in development, you use the npm package. You really only use the cdn if you're a beginner
Both React and Vue are made for single page applications, so when you bootstrap the project, it'll start with a single page.
However, you can use a tool like React router or Vue router to make multiple pages easier.
It is incoming request to framework
def user_interface(request):
after dir(request)
['COOKIES', 'FILES', 'GET', 'META', 'POST', '__class__', '__delattr__', '__dict__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__gt__', '__hash__', '__init__', '__init_subclass__', '__iter__', '__le__', '__lt__', '__module__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', '__weakref__', '_cors_enabled', '_current_scheme_host', '_dont_enforce_csrf_checks', '_encoding', '_get_full_path', '_get_post', '_get_raw_host', '_get_scheme', '_initialize_handlers', '_load_post_and_files', '_mark_post_parse_error', '_messages', '_read_started', '_set_content_type_params', '_set_post', '_stream', '_upload_handlers', 'accepted_types', 'accepts', 'body', 'build_absolute_uri', 'close', 'content_params', 'content_type', 'encoding', 'environ', 'get_full_path', 'get_full_path_info', 'get_host', 'get_port', 'get_raw_uri', 'get_signed_cookie', 'headers', 'is_ajax', 'is_secure', 'method', 'parse_file_upload', 'path', 'path_info', 'read', 'readline', 'readlines', 'resolver_match', 'scheme', 'session', 'upload_handlers', 'user']
I think I could make the same with
f'{request.scheme}://{request.get_host()}'
technically it should be same thing
looks better solution too
hi, i'm coding a django rest api, i have a question, is anyone know how to get id, or whatever, like my url looks like /polyrent/modules, but i wanna get for instance id, when I use /polyrent/modules/id, i do not get any id...
you can use HyperlinkedIdentityField or you can use another view to get serializer but id
@nimble epoch HyperlinkedIdentityField works for all fields? if i wanna get name, ect?
you want to get fields?
you can use loop then get index name out of it
i see, thank you
what's the point of having flask forwarding a request to django? that sounds nonsensical
You use Flask or Django, not both
yup. It is like buying a ticket to airplane, but instead of it travelling in train
or may be even more humorous. Having one leg in airplane, while second leg in the train
urgh. sounds horrific
I already wrote the answer
f'{request.scheme}://{request.get_host()}'
this is perfectly acceptable answer for Django
just stop it
f'{request.scheme}://{request.get_host()}:{request.get_port()}'
better with port
more accurate
REST
it does not matter
my question not needed those details
as I said, just stop
we already found the answer
what does {request.get_host()} do? wouldn't this return the host of the client instead of your server?
you know, very good question
Returns the originating host of the request using information from the HTTP_X_FORWARDED_HOST (if USE_X_FORWARDED_HOST is enabled) and HTTP_HOST headers, in that order. If they don’t provide a value, the method uses a combination of SERVER_NAME and SERVER_PORT as detailed in PEP 3333.
Example: "127.0.0.1:8000"
Raises django.core.exceptions.DisallowedHost if the host is not in ALLOWED_HOSTS or the domain name is invalid according to RFC 1034/1035.
according to documentation
I will check just to be sure, which host it is
ah no, it will be the server's information
i mixed up host with origin
I will make full check anyway
you can't be sure
unless it was tested
got it.
it was actually
f'{request.scheme}://{request.get_host()}'
because get_host contains already port too
so, get_port was not needed
returns server address correctly
good to know 👍
is Wix good to make a website?
need a payment system that also takes the users discord ID and adds it to database
No wix is not
If you need a payment system, use a proper backend with a tool like Stripe. Wix does not have a backend
Things like that with backend integration and be done in a somewhat reasonable mannor cannot be done with something like wix, weebly or others
Or use patreon
Which is what most people choose to use for bots
If you're want to take the time to set it up yourself, something like Stripe would be cleaner.
If you don't want to set it up yourself, Patreon is probably ebtter
so i have 0 experience with this stuff, basically i just googled website design, saw wix and started using it, but never finished it because i wanted to make the premium command for my bot first
honestly was just thinking of paying someone to do it for me
unless this can be easily done?
but i have no idea where to start or how to use things like stripe etc
Hi
Paypal sounds like a good option if you don't know how to use Stripe
To make a website, you'll need to use html, css, and js
Probably with a Django, Flask, or FastAPI backend
Those online website makers are not good
so with no idea how to do any of this, where should i look to start
i started using wix because setting up the layout and look of the site is very easy, but no idea about the payment stuff
🤷
Wix is not a good option
It doesn't have a backend
For html, css, and js, there are a number of online tutorials you could learn from
Wix is terrible
Wix and weebly are just bad
I've used it in the past too, and it was such a pain
is running a website expensive
Hosting one? It's possible to do it for free
Using something like Heroku with Netlify
well it depends upon factors like size, scale, function and other factors.....
But for just starting out or small scale, it could be done for completely free through services like glitch.com and repl.it
you need help?
hey could someone please help me here?
i've made an api with flask and everytime i run it, it shows me this:
is there any configuration i need to make or is it showing me this because i'm running this on localhost
If you're on localhost, you can ignore that
i've turned debug mode off
ight, ty
?
anyone know how i can deploy django with daphne if i'm using asgi/channels?
I have a javascript question. I have the following code.
const animals = ['Hen', 'elephant', 'llama', 'leopard', 'ostrich', 'Whale', 'octopus', 'rabbit', 'lion', 'dog'];
// Create the secretMessage array below
const secretMessage = animals.map(animal => {
return animal[0];
})
I'm learning about iterators on codecademy. Why, inside of the map method, are we defining a function animal and then treating animal like a value when we index it? It's confusing to me that animal seems to be acting as both a function and a value
what you're using there is an arrow function. Arrow functions are kind of like lambdas in python, where they have no name. animal is the parameter for that function, so that's why it's being treated like a variable; it is one!
@naive crater Thanks, and I appreciate the connection to lambdas in python. That is totally weird, but at least makes sense. It has been a bit of a trip coming from python where there is really one way to define a function (dunders withheld) to JS where there are at least three ways
Yeah, I tend to write arrow functions with parenthesis around the parameters so it's less confusing, like js (animal) => {return animal[0];)
Not sure if that helps, but it makes more sense to me
That definitely helps my brain feel more at ease with the syntax

Thanks 🙂
@naive crater Is there a rule of thumb you use for when to use the normal function declaration function functionName(params){ ... } vs an arrow function?
vs assigning an anonymous function to a variable
I'm not really sure, my personal decision comes from whether I'm going to use a function again
if I'm just passing it into an event listener once or something, then I'll use an arrow function, but if I'll be reusing it then I'll define it normally
Ok cool thanks.
Personally, I use arrow functions with methods like map or reduce.
Thanks 🙂
Can someone help me understand xpaths? Specifically, when I use selenium and input in the terminal:
Building = driver.find_element_by_xpath("//*[@id='span_tab_1']/table/tbody/tr/td[2]/div/a")
Building.click()
it works fine. but when I run "Building.click()" again I get the following error:
selenium.common.exceptions.StaleElementReferenceException: Message: stale element reference: element is not attached to the page document
BUT!!! if I press the up arrow key twice and reassign using the same the xpath, and then use "Building.click()" again, it works. I'll accept "it's a selenium thing" as an answer, but if there is something else going on in the background of the web page I'd like to know. Thank you!
can celery not run async/asyncio functions?
no iirc
or atleast
not by default
and if i remember celery is thread based which causes alot of issues with asyncio
oh I see, because I'm getting the error: 'channels_realtime_price' was never awaited result = (True, prepare_result(fun(*args, **kwargs))) so it's calling my functions and just getting a co-routine object back.
is it possible to call asyncio.create_task within sync functions?
tried to do it in my celery task - didn't work. also tried to start an event loop (within the same function) but that didn't work. guess it's sync functions for me.
I have no clue (still) how asyncio can run concurrent tasks within the same thread on a fundamental lvl, is that an issue?
err sorta
if you intend to use asyncio then i would recommend getting to grips with the ideas it uses to work
e.g. co-operative multi-tasking
maybe look at https://realpython.com/async-io-python/
big thanks 👍
import socket
server= socket.socket()
server.setsockopt(socket.SOL_SOCKET,socket.SO_REUSEADDR,1)
server.bind(("0.0.0.0",8080))
server.listen()
cl,addr = server.accept()
print("Povezao se Klijent",addr)
zahtev = cl.recv(5000).decode()
print(zahtev)
why am i getting a "'utf-8' codec can't decode byte 0xfc in position 8: invalid start byte" error
when the guy wich wrote the same code on yt worked perfectly
I am trying to build HTML string with data returned from database like this:
res = get_object_or_404(MyApp, id=id)
html_text = ""
html_text += "<h1>" + res.field1 + "</h1>"
How can I clean res.field1 if it is not coming in a POST request? Is there a generic alternative to cleaned_data that I can apply?
i fixed it i had to type port 8000 btw why does that only work on that port
The Pallets team just released Flask 2.0! (and Werkzeug 2.0, Jinja 3.0, Click 8.0, ItsDangerous 2.0, and MarkupSafe 2.0) Spread the word on Twitter: https://twitter.com/PalletsTeam/status/1392266507296514048 and Reddit: https://www.reddit.com/r/Python/comments/nacc83/new_major_versions_of_flask_jinja_click_and/
New major versions of all the Pallets Projects have been released! Read our announcement and the changelogs, and try them out today! https://t.co/WJ8GB3uISW
Flask 2.0 🐦
Werkzeug 2.0 🧰
Jinja 3.0 ⛩️
Click 8.0 🐁
ItsDangerous 2.0 ⚔️
MarkupSafe 2.0 🛡️
I'm taking a break now, it's been a long day, but I'll check for questions there and here tomorrow. 😄
Thanks for working on that!
super neat stuff. async views and callbacks is great, and I'm a fan of the @app.post and @app.delete decorators as well
hi
<button class="dropdown-button" onclick="dropTheMenu()">MORE ▼</button>
<script>
function dropTheMenu() {
document.getElementsByClassName("dropdown-menu").style.display = "flex";
}
</script>
im trying to change the display to flex when someone clicks on the button.
I'm planning on doing a large project , so I decided to deploy backend services as microservices , because I wish to scale it in future so it will be easier if each section of backend is separate
Should I use docker or kubernetes ?
and I've never done a project with microservices , so should I host every microservices on a different server or just run multiple docker or kubernetes containers on a single server.
it's a button!
Probably no, use a div
ok
.nav-menu .drop-down > a:after {
content:"\ea96";
font-family: 'Kanit', sans-serif;
padding-left: 5px;
}
.bx-left-arrow-circle:before {
content: "\ea96";
These are in 2 CSS files
<li class="drop-down"><a href="#"><span>Drop Down</span> <i class="bi bi-chevron-down"></i></a>
```HTML file^
https://cdn.discordapp.com/attachments/818357355304845362/841928938360012830/Screenshot_2021-05-12_at_12.14.57_PM.png
There, as you see, no image - the arrow does not appear
Any idea why?
docker and kubernetes are used together, those are two levels of abstractions.
docker packs your single microservice application into container
while kubernetes allows 'orchestrating' containers to be deployed in multiple amounts to balance the load
docker would be recomended as minimum usually ;b
whatever if you would use kubernetes is up to you
doesn't work
BRUHH use a div wus just an initial advise
:*{
So is kubernetes making a cluster out of my docker containers
I read we can deploy upto 8 docker containers on a single server, so what's the use of clustering them anyways
for easier... scalability in width.
you can setup for example in kubernetes:
Make 4 replicas of my application A
and install service for distribution of traffic between four of them
I don't know a lot about it, but the point is with easy deploying
4 replicas can be auto deployed at the different machines
you aren't tied with your scenario to one machine
this is sort of opposite to scalability in height
Oh it's clear now , so it's for disturbuting traffic by making replicas
Thanks🙌
this is one of examples
supposedly there can be other uses
I just know only this one)
also it can be used perhaps as alternative to Ansible
for example your application needs additional services
Redis and e.t.c.
how can I get returned data from AsyncResult object in celery
Probably kubernetes scenario can automatize stuff like that too
to deploy a whole pack of what your application is needing in terms of different containers
in one pod
and the pod is then replicated
oh ok so the DB is shared b/w them?
that's up to you, how would you setup your db
if you want it to be shared, it will be shared
Kubernetes gives you full control to make whatever devops you wish
to scale your application in your way without dependency on your VPS/server provider
Ok 👍
no, in which point?
js is web application afaik, what does django do ?
js is for frontend and django backend
what about flask
backend
is there any python library that is for front end ?
im not sure
quart is backend as well right ?
i dont know really
ok
i think its for backend
how can I iterate a AsyncResult object from celery?
Hello I am new to this channel and I have one question in wich Python module you work?
I use flask... But many use django too! I don't have much idea of other python web development frameworks...
which one you need help with?
I know Django, and a bit of Flask, FastAPI
yea , flask is the only for me currently, and still I dont know everythin about it yay
Jinja comes by default in, most of frameworks, it can be easily used even without frameworks too. Discord bot with jinja is awesome.
Everything else from js you can attach too though
Not sure how goes situation if you need additional js libraries though
Probably npm should work
Technically stuff like wtf/forms, unsure how it is called, provides easy pure python front end too
Put the character in the html, not the css
The \ea9 part
As a general rule of thumb, content goes in html, while styling goes in css
Yeah I got it
Thanks anyways
so yesterday i was asking about website hosting and creating a website
learned all the bad things to do 😄
anyone here use ionos? is this good to use?
What do you want to do with the website?
Use a website builder, or just buy a domain?
well ionos offers both i guess
but, building a website with payment systems to use with a discord bot with premium features
Do any one know how to link an HTML file to CSS file in visual studio code
Do you mean import a css file into an html file?
yeah
In your <head>, do <link rel="stylesheet" type="text/css" href="path to css file">
For example, ```html
<head>
<link rel="stylesheet" type="text/css" href="index.css">
</head>
Thanks for helping
Giggles. Dunno how much efficient this writing
but...
with simple js
<script>
fetch('/server').then(function (response) {
// The API call was successful!
return response.text();
}).then(function (html) {
// This is the HTML from our response as a text string
document.getElementById("demo").innerHTML = html;
console.log(html);
}).catch(function (err) {
// There was an error
console.warn('Something went wrong.', err);
});
</script>
<p id="demo"></p>
I could use my django
to render stuff while getting extra stuff from API endpoints!
it has potential for a smooth front I hope
I could try putting inside API stuff, pre rendered by Jinja template!
it should make my front logic quite simple
I have a FastAPI project with the follow structure:
Project
- app/
-- __init__.py
-- main.py
-- database/
--- __init__.py
--- db.py
--- models.py
Inside main.py I want to import the models from models.py as well as some functions from db.py.
When trying to import like this:
from app.database.db import functionA, functionB I get an error no module named "app" . I've tried some other ways of import as well but I don't really understand how the packages/modules in python work when nested like this.
Can someone help me with this/help me understand so I can start doing it correctly?
client-side rendering will hurt your application's SEO badly.
I am afraid that, long re render will hurt more
my web site has one large table of things
based on selection of one of strings
it needs rerendering quickly small sticky table near the bottom
and well... the general goal of the web site is making quick navigation through the database of tables
quick rerender with javascript should make things much nicer experience for users, than full re render
yeah - that's right, but are you re-rendering the whole webpage or just modifying a DOM element?
with javascript? just modifying DOM element at the bottom 😉
ah gotcha. I thought you were moving from server-side rendering to client-side
actually this is interesting to try as well
perhaps rendering the main table with JS too
I'll have at my server side it fully prepared, pre-rendered with Jinja
leaving at client side only to pull it
I'll think about it later, for now I'll pull with JS only secondary table
which I could not be rendering smoothly without JS at all
agreed, that's why frameworks like react have all of the appeal 🙂
I am not ready for React yet I think
react is very easy
learning how to do this stuff semi manually should be better experience for me for now perhaps I think
if you can read a little bit of JS and write a function in JS you can do react
Do browsers automatically set X-CSRF-TOKEN if we just supply the csrf-token as a cookie?
I am using flask and flask_jwt_extended seems to set some csrf token cookies which it expects as headers to validate further requests.
yeah React is easy, most of the learning will be done learning third party libs. like redux etc.
I did not try React yet
but I already learned how to deploy it%
our front ender did not know how
no, the browser doesn't, but some popular libraries like axios automatically add it as a header if its in the cookies (it needs to be named specifically as they expect though)
Considering that this current project I do mostly out of learning.
I'll probably first will make JS/Jinja render
and re learn how to that in React after that
it will give chance to compare which way is easier
well if your project needs interactivity and a lot of JS, then React will always be easier. You don't get state management, hooks etc. that react offers with plain JS (well, you do, but it's a long setup).
i recommend it highly
If I'll be able keeping my code dry as it is
I'll have only two JS functions.
- Pull main table of the current section
- Pull secondary table based on selected row in the first table
it should be managable without react
yeah definitely
How to make stateless files in NodeJS like with PHP which is deleted at the end of each request without creating caching problems via modules or exports ?
errr you sorta cant
PHP and NodeJS differ in their execution alot
and Node and the JS system in general is not designed to do that
So NodeJS is useless then?
There are other programming languages that have the same logic as PHP ?
In your case, Node.js may be useless, yes.
if this is for a static site then yes
At the beginning, I wanted to make a site in PHP, the problem with PHP is that the types have problems and that there is no asynchronous and the calculation in PHP is slow
I went to NodeJS, I feel trapped
I don't know if Rust / Go will have the same problem if ?
If you want to use Node.js, you should use a JS frontend usually.
well
I have the impression that doing a simple MVC in NodeJS is very complex
in PHP it becomes easier but PHP has many problems
PHP and Node are both used for backend, so there's really no point in using both (unless I'm confusing PHP with something else)
You might wanna explain what your goal is here a bit better
Rust, Python, Go, NodeJS etc... can all do the same thing
My goal is to make a simple dynamic site with NodeJS
I came here because I had a problem with the requests since it keeps cached via the requires of the old request
If there is a new request, it will be impossible to retrieve the current request since I stored it in a class via export.request = request or module.exports = request
I have to do a request.reset() at the end of each request to empty the attribute in the Request class
I don't know, if there will be a problem when I have a lot of requests at the same time
I just wouldnt do that
So if making a simple site in NodeJS is complex, then making an API / API Rest in NodeJS is complex too
APIs can be (relatively) easily made using express
Well if you want some global var stuff (which you really shouldnt do) you might wanna consider Flask with python
but generally, you avoid and shouldnt use globals as much as possible unless they're constant
the reason PHP can get away with the global and changing state is because it's directly synchronous so it can correctly handle the global state without invaliding it
with asynchronous logic its a very very dangerous game
I do not want to use a framework whatever the programming language used
I wish to do everything since the native language
In some cases, I need to do Asychrone, Pipeline, Stream
PHP is a bad programming language, it's cruelly lacking structure, other languages have good structures
you want to write all the framework stuff yourself?
If you dislike PHP, why are you using it?
Yes I want to use without framework myself
I no longer use PHP, it was at first to test the possibilities of this language, I selected negative points when I want to do things
So which language are you doing it in then?
Do you want to use it for production?
After, I'm a big fan of Python, the same python is slower than php, I'm disappointed
if yes, I sorta gotta recommend against it
In the end once everything is made everything runs pretty much the same speed
cuz like most stuff on the web, the slowest thing is the IO not the language
Python is plenty fast enough for most things. Unless you're doing something that needs speed, then Python should be good enough.
Yes it's for production
then i can only recommend against making the framework and socket interactions yourself really
Production grade HTTP servers and frameworks are HARD
there is so much logic and behavior as well as security you need to get correct in order for it to be production ready
If language plays an important role, for algorithms
May I ask why you don't want to use frameworks/packages besides the core language?
trust me im on iteration 3 of my webserver and framework just to correctly support HTTP/1 + be secure + be efficient
I hated the frameworks, it's bad programmed, their programmed way scares, too much calculation for nothing, too much line of code for nothing, no structure etc etc, "we can not make the generality only by making case by case and not of the generality to make the case by case "
I wish to create my own stuff, it's safer in terms of performance, structure, logical
I can guarantee that the existing frameworks that have existed for a while, will be better coded than what you can make, not to insult your coding ability but its just they've existed for longer, have hundreds of maintainers, security patches and thousands of tests.
As for performance it's really not
the language performance or framework execution performance in reality means almost nothing when everything is setup because IO takes time, databases take time etc...
There's just some things that can come from hundreds of people working on a project that one person simply can't do.
Try to make algorithms and you will see a big difference in terms of performance, try to do less code line and you will see
If we use frameworks / solutions all done, we can never understand the real problem
Sure, but algorithms are alot diffrent to production grade frameworks lol
and also algorithms are generally CPU bound problems
not IO bound
if you have a server that can handle say 7,000 req/sec (doesnt sound like much) you get hundreds of BILLIONS of requests a year with that
I have no problem with the CPU or anything, my only problem is the language that is limited to keep information and is eliminated at each end of the query, a bit like PHP logic, that's Well, I'm trying to do this kind of logic
Well dont if you want it to be asynchronous
because that's how you run into state invalidation and race conditions
as a warning though Premature optimization will be the death of your project if you dont think about other things first
because Fast != good, maintainable and secure
So the number of request per second is a big debate, I managed to test up to about 500000 queries / seconds
Asynchronous perhaps interesting for IO
okay sure
but you wont ever get that in reality
and if your db gets hit that much then your setup is wrong
even 7,000 req/sec equates to billions of requests over a year
which is the size and scale of some of the largests websites in the world that run thousands of servers
I do not optimize premature, I'm testing, I do my features and I see how I can improve it
For databases, there are replicas as well as other solution, after all depends on the need
Sounds like its premature optimizations to me, but hey sure your site might be Wikipedia level big with thousands of servers and your databases are so hyper optimized that they take nanoseconds to get data and the framework and language is absolutely the bottleneck
What worries me in the web is that the pages are slow and the weight of the pages are heavy, we are on average to more than 2 MB per site page, there is a big problem
and guess what :P thats nothing to do with the language or framework
and web pages will only continue to get bigger
because sticking static apps like React and Vue which client side render and can be served globally on CDNs is considerably easier than server side rendering and scaling and browsers are getting quicker to render them
New tech like webrender makes most CSS performance tricks obsolete now lol
If your pages are more that 2mb, that sounds like a problem, unless you're in a special scenario
oh yeah
most pages are not 2MB though
maybe in total with every page loaded with assets
I quote 2 MB who is an average, I generalize? so there are advantages and disadvantages when using frameworks / languages
I still don't see the disadvantage to using a framework
I do not have a bottleneck, since you talk about it
saying that even with that my entire webpage which is a all in one site transfers the entire page in fractions of seconds with lazy loading with kb chunks
Your pages are compressed ?
pfft no
Lazy loading is super useful
that's a first problem
how so? We dont need it, and for the size of compression its not worth it to us or the user
It takes < 100ms to load everything
on a site that is very much not optimised
For a blog, personal site, we can not care about performance, however for a professional site it's important to be efficient and optimized
then use a professional grade framework dont try make your own that will be unbattle tested, lacking in certain areas etc...
If our framework on clojure which runs at the same speed at python can handle the some 2.5 billion row + database and millions of monthly requests
I dont think the framework matters 
and if you still dont believe that look at some of the big sites like Instagram, Discord etc... that still use Django and Flask which even in python are considered 'slow'
cuz in reality like i say
the framework isnt the slowest thing
I simply adapt to my problem, it's not really a framework that I'm trying to do
I have already used frameworks, I am very disappointed with the way it is programmed,
Frameworks pollute the web and computer when it's badly designed
So you're basing your opinion of all language's ecosystems and frameworks on one other language 
(even though those frameworks still power some of the largest sites in the world and have been battle tested through most of the web's life)
And you're saying you can do better than something that hundreds of people that have contributed to?
If so, go right ahead.
anybody know how to fix or disable STRICT MIME TYPE CHECKING on django. It doesnt allow me to apply any CSS Style sheets or use any .js files
and yes in all my tags i use type='text/css' etc.
Honestly, for years that I'm looking for simple and innovative solutions and it works, I do not finish everything but it's good
I am convinced that my solutions will work, it remains for me to pay the stairless query story as php logic
If this is coming from the browser which i assume it is, then it's an issue with how you're loading them / behaving with the HTML rather than the server
can you share the meta tag block and the error?
Hi All, I have developed a game using pygame. How can I host it on a website? I am planning to use Heroku.
you cant
Websites are a whole other ecosystem to native type games like pygame
whole other ballgame
if you mean just like, make a website for it and people download the code then yes its possible
I was looking at libraries like pyjsdl.. would it work?
any other alternatives instead of pygame to make it run on website?
error from browser console
Refused to apply style from 'http://localhost:63342/static/index_assets/vendor/bootstrap/css/bootstrap.min.css' because its MIME type ('text/html') is not a supported stylesheet MIME type, and strict MIME checking is enabled.
html tag
<link href="/static/index_assets/vendor/bootstrap/css/bootstrap.min.css" type="text/css">
django
return render(request, 'index.html')
## render = django.shortcuts.render
django responds with 200 so i assume its just the browser
generally no
unless you want to re-write it all in browser JS or explore the wacky world of web assembly stuff with another language like C, C++, Rust, Go etc...
Python doesnt compile to wasm though
<head>
<script data-ad-client="ca-pub-2387817887649725" async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<script async src="https://arc.io/widget.min.js#orJQqvxn"></script>
<meta name="theme-color" content="#f54646">
<title>Home</title>
<link href="/static/index_assets/vendor/bootstrap/css/bootstrap.min.css" type="text/css">
<link href="https://fonts.googleapis.com/css?family=Catamaran:100,200,300,400,500,600,700,800,900" type="text/css">
<link href="https://fonts.googleapis.com/css?family=Lato:100,100i,300,300i,400,400i,700,700i,900,900i" type="text/css">
<link href="/static/index_assets/css/one-page-wonder.min.css" type="text/css">
</head>
thank you
Hmm interesting
Can I install pygame as android app may be?
it loads everything fine with debug set as True
yes then stuff breaks
you are using something like nginx to serve the static stuff dont you?
not just use the debug server
If what you're doing works, is there a question you have?
not as of now but in the future once its done yes
ah well
when Django is in production mode (DEBUG=False)
it doesnt serve static content
because in production you a) shouldnt use the debug server to run django and b) python shouldnt serve the static files
any reason to that?
performance and security mostly
basically i'd keep to using Debug mode till you're ready to deploy
then collect static
then stick behind a reverse proxy and let it serve the content
take a look at corey shafer's videos on Django and deploying it 😉 Should work a treat
I separated the operation after I gather everything to see how it will react
It is this query story that does not delete in the end and can be mixed with the old and new request of another user, the problem is complex,
I am trying to do the same functioning of the requests that php that there I find interesting
(and you're trying to do that in a asynchronous runtime where the state cannot be guaranteed to be in the correct context for each request)
just as a addition to that note :P
How do you feel about WhiteNoise for serving static content? It's written in Python and the docs explain why that's generally ok: http://whitenoise.evans.io/en/stable/#isn-t-serving-static-files-from-python-horribly-inefficient
According to my logic, there is very little asynchronous in my code,
It seems to me that this is not a better resset solution the value of the class instance variable that has been "required / export" at each request of the server
I am obliged to give (Req, Res) to all my functions even when I think it's useless in some cases
I'm now using Traefik for reverse proxy & ssl termination instead of nginx, but traefik doesn't serve static files
while it would be possible to have nginx behind traefik I guess but idk if that makes sense
whitenoise seems nice, on the other hand it's not asgi-ready
(but should be soon)
just because your code maybe doesnt look async, doesnt mean it isnt, you're in the JS world now. Everything is async and there are 3 different types of core executions
Welcome to the JS event loop setup :P
whitenoise seems alright
though it's not something i would still use just because Nginx is just so hyper optimised
not that python cant do as well, but unless it's using os.sendfile it'll struggle
Have i introduced you to my good friend Kong
I haven't heard of it
I wanted to ask whether it would make sense to have nginx behind traefik for static content, I'm such a web noob that I cannot tell
so nginx does all the heavy lifting but kong gives you all the pro's of traefik
Personally i prefer kong because it requires less nonsense configuration like traefik and it doesnt try shove paid features all the time
That's the problem, once the query arrives, I recover the query object that will be stored in a class that is supposed to be empty at each request (same principle as php), I block on that
So if multiple requests arrive simultaneously, I risk having a problem I think
has a nice open source web ui aswell
so dont try behave synchronous in a asynchronous system. If you want my advise; If you're gonna try do stuff 'better' than the existing frameworks atleast obide by the language semantics and dont try to work against them
the immediate downside to konga is that I'm googling for information and getting pictures of monkeys 😔
Thank you for your advice, however I am allergic to the frameworks xD
So how to use a JavaScript file in nodejs without being cached by the "Require" ?
on the other hand traefik resolves to the pesky gopher
so I guess it's not much better on that front
So much for the trying to be better ig
thanks 🙏
By far the nicest thing is you dont have to deal with traefik's setup of using labels etc...
you can live reload extensions, built in proxy cache etc...
I don't know, I found traefik very pleasant to work with
but I deploy to kubernetes using a pre-made helm chart so maybe that's why
I'd definitely recommend giving Kong a go 😅
Personally i prefer it, I know others will swear by traefik
but generally a avoid software that tries to pressure you into their cloud enterprise setup for stuff that doesnt need it
yeah I probably will I haven't touched web much in the past so trying loads of different things is beneficial to me right now anyway
if only for the purposes of learning
😌
now back to my UDP hell lul
Otherwise I have an idea, how do you make to reduce the request information from another file without going through arguments (req, res) ?
Okay so that I have to go to all my functions (Req & Res) by avoiding stored in a Class that can be reused later then
what language is that?
rust
hello, is twisted still widely used or was it replaced by something in recent years?
My game dev book from 2004 recommends twisted
I got a question about flask, when the user tries to login and the server finds that their input info is wrong, how do I make the server tell them their info was wrong, how do I make the server push a label into the HTML document saying "invalid login info"
are you using any authentication libraries, or are you doing this all by hand?
doing all of it by hand
oh, wait, I found a way, I make a variable called "wrong info", if the login information is wrong that variable gets set to True and gets passed to render template, so jinga has an if statement block with the "wrong login information" label that gets activated if the variable is true
use the username and password from db, then use
if form.validate_on_submit():
user = User.query.filter_by(name=form.name.data).first()
if user and bcrypt.check_password_hash(user.password, form.password.data):
login_user(user, remember=form.remember.data)```
to check if the username and password, next, if the input is incorrect, use "else:"
oh, nvm
hey so im making a discord login for my website
and i have some issues with oauth2
it keeps giving me a keyerror for some reason
OAUTH2_CLIENT_ID = os.environ['839258071439900733']
File "D:\Python 3.9.1\lib\os.py", line 679, in __getitem__
raise KeyError(key) from None
KeyError: '839258071439900733'
thats the error
There is function flash mentioned in flask mega tutorial. It can flash messages to user in such situations
I don't wanna flash messages, I wanna insert an HTML element, because I want it to be styled with CSS
It is styled too
how do I style it?
Question regarding React
we have a project already running with npm, build, serve, package.json. It is more or less half backed React project. Full of different npm libraries.
How much of hustle would be attaching webpack to it at this stage?
I am unsure if it would take just few minutes or... it would take much greater time
Its easier to force validation into the form than trying to flash it. Are you using a form library like flaskform?
email = StringField("Email", validators=[DataRequired(), Email()])
password = PasswordField("Password", validators=[DataRequired()])
remember = BooleanField("Remember me", default=False)
submit = SubmitField("Login")```
could i ask a question for research purposes based on wordpress?
Guys, how do I create some backend python script that checks the formatting(Grammar) of YAML files?
perhaps better just to find some library that checks for you
I implemented this directly in my HTML using the builtin form errors.
If it has any errors, it will create the form field with the invalid class which I use to add a red border, as well as show the error message below the form field.
I use this since it is nicer for the user to see where the error is instead of flashing everything in one big message at the top or bottom of the screen.
In my case it looks like this:
What's the use case of micro-services? In reality, are micro-services just small API sections of a monolithic web-app?
probably cause they are just more simple
I'd say the exact opposite.
more or less correct
and due to them being splitted into separated small API sections...
it can be more easily testable/developed and e.tc.
can they be more flexable
it can make your logic also more DRY
due to one application making it good
while other apps use only this one for that
Yeah I'm looking to make micro-services for my next project, I could even incorporate them into my own. I'm just wondering how to go about the devops side of it, how do I start?
sheesh should i move to flask
I saw nice O'Reilly books about it, going to read it.
But the first question you should ask... what are your developing
miscroservices model is similar to db models in how we think it should be
when we think about required db models in SQL, we think about interactions between them with foreign keys
microservices model is more or less same in this case
you need to think what should be separated, why it would be better separated, and how your applications going to communicate between each other
Okay okay. I will check this out bro. Thanks
the most often case: we separate web site to backend and front end applications ;b
Well, I've got one monolithic app for data retrieval & visualization. I want to add ML to my project, and then a seperate API for my ML model.
I wanted to move to micro-services to decouple the application and allow for more isolated testing. I feel having everything in one monolith will have less effective testing.
how many developers do you have on your project?
I'm solo, it's just personal
not sure if there would be real proffit from microservices then
it is supposed to be good when you have more than one developer
it can bring you good with enforcing better application separation by design though
it can help you if you struggle to structurize your application with separated logic from different sections.
i think, if you aren't having struggle to refactor your application/writing tests on your own, then you can go without microservices
but as I said I did not read the book yet
so I can't say for sure
it is just looking to me like overkill to make microservices when you are solo developer
microservices can be also used... as better way to scale your application
it can be also good then for your even solo usage
think for yourself, if you need some part of your application section scaled independently from each other
Well, I have been refactoring a lot recently and although now it's more usable, once I add my ML models and API it's going to be large...
So, if I have my django app serving as my backend - and I want to add a micro service for a frontend feature. Should I make API calls from my backend or my frontend?
Is it normal to have one monolithic app connecting all the micro-services?
if you feel like your app would be really large.
then go for microservices I guess
another point of microservices to lessen load on your cognitive resources
the less you can keep in mind about one application, then better
But like... should my monolithic app be a "centre" between my micro-services?
I need to read a book on it, idk if I deploy my micro-services if i also need different domains for each API
if you separate to micro services, why would you have monolithic app?
your each microservice does only small part job
and all results outputed to your front end site
there would be nothing monolitic then
you are usually having monolith or microservices
not both%
although nothing forbids from having a mix of them
Has anyone worked with Django & Hotwire, and could share experiences 
@inland oak yeah, I mean if I have my microservices I need to connect them somehow, so would I have one server handling that?
Also each microservice in this case would be a seperate django server? Or can they all be on the same server
Technically, aren't seperate django apps microservices? Or do they have to be on different servers? (So if an exception is raised, only the one server will fail)
not if you host them in the same project
the idea of a microservice
is that it can be stood up and scaled independently
@vestal hound so each project has to be deployed seperately?
yes
and be independent
okay example
Insta
you could have an image service and a chat service
image service takes care of uploading and viewing images
chat service takes care of chat
so let's say
people happen to be talking a LOT more today
you can independently scale up the number of chat microservice instances
I see... so will the frontend make requests to each microservices or will there be a single server which orchestrates all of the microservices? I'm thinking the 1st option.
it depends
the latter
is something
called
BFF
backend for frontend
which is a p common pattern
in cases where your app is simple
or the microservices exist only for your frontend
a BFF is unnecessary
that's more appropriate
for situations where there are multiple frontends
and multiple microservices
and each frontend consumes a subset of the microservices
so an intermediary layer makes things more convenient
that also allows you to add, for example
default functionality in cases where individual microservices are down
that varies between frontends
Yeah, thanks for the know-how. I have a django backend for react frontend, and I was thinking to have that server orchestrate between the microservices.
Do you think I should learn docker before diving into this?
docker is usually must have for microservices
containerization helps for easier deployment and dependency control
some form of containerisation
you can go without it, but it would be just less comfortable
they all interact.
one of the big selling points of a microservice
is that you can scale it up
stateless containers really help with that
so on top of Docker or whatever you choose
you have a container orchestrator
having all this managed for you
is really nice
e.g.
EKS
or GKE
(AWS Elastic K8s Service/Google k8s Engine)
Can you help me to find out how can I use python instead of PHP.
So I have a fully working html, css, JavaScript site and I want to use python to connect for sql.
Thanks
You can use django and django models or flask and flask_sqlalchemy
thanks I will try
yw
Is anyone aware of where to find part-time volunteer opportunities for working on Django sites. I want to get back into Python and Django specifically.
Traceback (most recent call last):
File "main.py", line 3, in <module>
app - Flask(__name__)
NameError: name 'app' is not defined```
thats clear bro
Hello everyone, I'm learning authentication with token in django rest framework.
I wrote the code and it works when I send token in the header.
But how can i automate this process?
Like once the user logs in, token should be sent in each request
@vestal hound so in production, are each of the containers on seperate VMs? So you can have more/less VMs allowing for more scaling?
How would I setup ci/cd for different microservices, should each be in a different repo or can I have different ci/cd scripts for each branch?
@foggy bramble use JS to attach the token cookie to each request
Does that mean frontend will handle this
first save token to localstorage
Do you mean the computer of the user?
yyeah i think
Do you have any sample code showing implementation of that..?
ok you using frontend?
Because any tutorial i found on the internet is just showing how to create token and send the token in the head using postman.... But what I'm thinking is that users won't use postman and enter the token each time, so we need to automate
Nope I'm interested in backend
so i dont think that you need token auth
Whatchu mean?
you use that user token in frontend to show that a user is logged in. i dont say that you cant just say that you dont need
@foggy bramble yes - you need to set a token cookie and attach that to each header. Do not store it in local storage, as localstorage data is only available on the clientside (and doesn't have expiry dates).
@nimble epoch Token auth / Session auth - it all uses tokens saved in cookies. I'm not sure what your alternative is.
I can't find any tutorial on implementation of this
i mean rest framework token that rest framework sets it to each user model
when you send request to that url a username and password is needed when you enter them correctly itll drop the token and you can get then token and save it somewhere
and of course you can use sessionStorage to save it and itll get expired after a time
oh nicky i just got what you say yeah he can use sessionStorage
No, store it in cookies. Not localstorage or session storage. These are only accessible by the clientside, but the server may want to change these cookies with a Set-Cookie header.
oh yeah you mean django cookies for example?
I literally mean cookies.
of course
I have a div container, which contains bootstrap table
I wish to receive result....
is it possible somehow to make them diving screen in three parts?
Table main has hundreds of rows
Table 3 has small amount of content to fill itself fully
Table 2 has content to fill twice of its size
looking for some tutorial for that
why dont you use grids?
Grid or flexbox
Thanks
then use table in eachone
greed is good
i mean if you want to have that table shape you can use table inside
I'll need to clarify end result
a moment
green shows three vertical scroolbars
which I would need for each table
grid should probably suit my case, right?
I have just completed Django
Made a Portfolio Page, Blog App, Polling App, Forms.
Can you guys suggest me what project should i do next?
I want to do a Big project that can be added in my resume
yeah
yw yeahhh
i think a good model design is a kinda portfolio
am i right?
like Follow system, Like, Comment
You mean a social media app?
yeah yw
If I want to port my current django app to docker, I use a redis installation on linux.
As well as installing python dependencies, am I able to install redis with apt?
i searched and found this ...https://www.digitalocean.com/community/tutorials/how-to-install-and-secure-redis-on-ubuntu-18-04 is it useful?
Will my redis / postgres DBs be in a different docker container to my django container?
They can be in the same one
you can do both, in different or same
For example, PyDis site has both the Django site and the postgres db in the same container
Ah okay. If I have django and postgres in seperate dbs, I'm a bit confused on how they can communicate - since they're in different VMs essentially?
I have somewhere example of docker compose scenario
which has Django, Regis, Postgres in different containers
version: '3'
services:
django:
build: .
container_name: django_service
command: >
bash -c "python manage.py makemigrations
&& python manage.py migrate
&& python manage.py runserver 0.0.0.0:8000"
volumes:
- .:/app/
ports:
- 8000:8000
environment:
- DEBUG=1
- DJANGO_ALLOWED_HOSTS=localhost 127.0.0.1
- CELERY_BROKER=redis://redis:6379/0
- CELERY_BACKEND=redis://redis:6379/0
depends_on:
- redis
celery-worker:
build: .
container_name: celery_worker
command: celery -A fampay_youtube worker -l INFO
volumes:
- .:/app/
environment:
- DEBUG=1
- DJANGO_ALLOWED_HOSTS=localhost 127.0.0.1
- CELERY_BROKER=redis://redis:6379/0
- CELERY_BACKEND=redis://redis:6379/0
depends_on:
- django
- redis
celery-beat:
build: .
container_name: celery_beat
command: celery -A fampay_youtube beat -l INFO
volumes:
- .:/app/
environment:
- DEBUG=1
- DJANGO_ALLOWED_HOSTS=localhost 127.0.0.1
- CELERY_BROKER=redis://redis:6379/0
- CELERY_BACKEND=redis://redis:6379/0
depends_on:
- django
- celery-worker
- redis
redis:
image: "redis:alpine"
it is not mine, but I hope one day to use it
perhaps it can be useful for you too
mm yeah, it is Django, and Celery/Redis actually compose scenario
tbh, not sure how it works yet. but I think it should be having 4 docker files (except redis, which uses prebuilt image)
each section has build, which I suppose makes another container
and each section is launches different container as far as I can read
Oh so, a docker file is a docker image? And within that image you can have different containers?
docker file is scenario to build docker image
converting your source code project to image ;b
A Dockerfile is a "recipe" for building Docker images
Alright, I'll watch some guides on it to understand it better
just usage of docker container
makes your application being easy to run on any machine with Docker, regardless to its OS version
because it wraps your application with specific OS inside of the container
helps for easy installing to multiple machines with different OSes
Programming with Mosh has a great video on Docker
A language agnostic one
Docker Tutorial for Beginners - Learn Docker for a career in software or DevOps engineering. This Docker tutorial teaches you everything you need to get started.
- Get the complete Docker course (zero to hero): https://bit.ly/3sO7Z5H
- Subscribe for more Docker tutorials like this: https://goo.gl/6PYaGF
Want to learn more from me? Check out the...
@calm plume do you know how I'd use docker in a ci/cd pipeline? Would I be creating a new container on each deploy?
I haven't done it myself, but I think you would generate a new container from the image
Or maybe you could use docker-compose
https://github.com/python-discord/site/blob/main/.github/workflows/build.yaml#L11-L58 Here's an example of a build
which yt channel and website would be perfect to learn django? any suggestions? I am new here and I'm looking forward to learn web development
The official Django tutorial is amazing. And I think Corey Schafer has a video series on Django.
Hello im using django rest framework and react. I have an Authorization and application/json in the react headers but it returns a 403 unauthorized when connecting to server . Why is this? when i test it in postman, it works
its pretty good on my screen
Looks like this to me
anyone here knows react with drf?
Oh the tables
I'll probably rethink what I do with loading speed though
The title is also a bit too large
nvm, my network problem, lol
eh, something got just broken)
all right, trying to limit size of container containing grid then
Has anyone watched django tutorial of yt channel called Clever Programmer?
if you have what would you rate on the scale of 10?
limited size of grid with
css max-width, max-length
but table just ignores the grid size
I do something wrong probably with table?
Stick a container around the table then
is it possible to fit the table into grid, and for table having its own scroolbar inside?
Or nest the table inside the grid
<div class="grid-container">
<div class="item1">
<p id="main">This is Main Table</p>
</div>
<div class="item2">
</div>
<div class="item3">
<p id="secondary">This is Second Table</p>
Footer
</div>
</div>
I already stick grid around table%
That <div> looks off
the table is <p id="main"></p>
The top one
well, it was just bad copy
.item1 {
grid-area: main;
}
.item2 {
grid-area: right;
}
.item3 {
grid-area: footer;
}
.grid-container {
display: grid;
grid-template-areas:
'main main main main right right'
'main main main main right right'
'footer footer footer footer footer footer';
grid-gap: 10px;
background-color: #2196F3;
padding: 10px;
}
.grid-container>div {
background-color: rgba(255, 255, 255, 0.8);
text-align: center;
padding: 20px 0;
font-size: 30px;
}
I'll try to start with stripping table from its style, perhaps they are the issue
reverted almost everything
http://80.78.247.245/
hmm, may be somewhere I could find working example
hmm, you didn't specify any grid-template-rows or grid-template-columns. In my opinion, I think it's much easier to use flexbox:
<div className="flexbox-column">
<div className="flexbox-row">
<!-- These two items are next to eachother. Specify their relative widths. -->
<div className="item-1"></div>
<div className="item-2"></div>
</div>
<!-- This item is below item 1 and two and takes 100% width -->
<div className="item-3"></div>
</div>
.flexbox-column{
display: flex;
flex-direction: column;
}
.flexbox-row{
display: flex;
flex-direction: row;
align-items: center;
}
also I just realized i wrote JSX not HTML. That's reacts toll on me...
also you can give your item divs a fixed height, and have overflow-y: scroll to be able to scroll through the table.
how to specify relative widths of first two items just to be sure? 😉
so for item-1, you can say width: 80% for example
ah got it
not yet at the finish
but getting closer
it works exactly like I wish
❤️
nice, FYI your item-2 has to have a width of 20 or lower to be on the same row.
if you want to jazz it up a bit:
.flexbox-row{
display: flex;
flex: 1;
flex-direction: row;
align-items: center;
justify-content: space-between;
}```
`align-items: center` will vertically center both divs in the row. `justify-content: between` will place both divs at opposite ends of the row. `flex: 1` should mean that both divs have the same proportion of the width of the row (if my memory is right).
Well, I am trying to link a CSS file to an HTML file. But it's not working ( Can anyone can help me with this )
I'm using django-authemail for login, signup, logout, password_reset, and password_change.
I want to override email message, anyone knows how to do that?
relative path: ../image/style.css
20 or lower? hmm weird, tried already much lower
http://80.78.247.245/#self
Thanks for your help
hmm yeah that is weird. Scrap the widths for each div and give the .flexbox-row: justify-content: between; and they should be on the same row then.
yes sorry, space-between.
well, it did not work
hmm 🤔
@inland oak you couldve just used bootstrap row class
i am almost close
I feel it
those flex boxes are exactly working like I wished
I have scroll bars as I desired
of course they do
oh nice, good to hear 🙂
Anyone here use jinja2 much?
i used to its similar to django template. you need help?
Yeah, just had a quick question about looping over an include
hey bro why u blocked me ;-;
yes sometimes i use jinja templating
So I'm looping over a list of dicts:
{% for post in posts-%}
{% include 'post.html' %}
{% endfor %}
And I want the included template to render each one using the data in the dict. How do I set "post" as the top level context for each time it loops include?
Hi guys, I have a really important question.
I want to build a website, like stack overflow but with much much fewer features:
==> users are able to post a question or answer another existing question
The only difference that I want it to be real-time/live whatever you call it
I want to use WebSockets so whenever someone posts a new question you can see it in real-time and neither when someone answers a question
however, I have no idea how to deal with these data and store them in the database
Could someone explain to me, please?
should I store the data that comes through WebSocket in the database!?
🙄
can u explain more nicely??
this is not the way to do what you are looing for
yes lol
u can fetch data from database by jinja not whole template
lol
{% for post in posts %}
{{ post.html }}
{% endfor %}
perhaps you are looking for this?
Helloo 🙂
u can ,use databases
u use flask or django @hot crest
Im going to use django
nice u can
Yea I know that I need to use Django but
I dont
Can you explain more in details?
Not quite; so post.html is a template. I have a list of dictionaries, and I'd like to render the template one time per dict on a single page.
@lament glade you want to iterate through each post then show then one by one in your page, right?
I'm not sure did i get this correctly, but u can use rendering the file in backend, then for loop and then show the data with certain var, lol
for websockets you're going to use django-channels. It'll turn your WSGI server into an ASGI server powered by Daphne. It's a bit complex to get your head around consumers, channels and the channel layer - so I recommend watching some youtube videos on Django Channels. If you don't know Django yet, then don't go straight into it. It will confuse you further.
rendered_posts = []
template = loader.get_template('post.html')
for post in posts:
rendered_posts.append(template.render(data=post))
return HttpResponse(loader.get_template('second_template.html').render({posts=rendered_posts}))
{% for post in posts-%}
{{ post }}
{% endfor %}
you are essentially trying to do something like that
you can pre render your posts with different jinja template, before submitting already rendered to new render template
@opaque rivet Yes seems like It needs a bit of time to learn
I already know Django and working with DRF mostly
But after all, lets say i made a connection between users with channels,
is that okay to store the datas in a sql database like psql?

