#web-development
2 messages ยท Page 67 of 1
:o
my browser is just prepetually loading
and timed out
hmm
uwsgi console said nothing,too
port 5000 is open, and i bound to 0.0.0.0
Can i use jinja syntax without importing django or flask
Try curl'ing it from the lcoal machine
I'd have expected that to work but you could have iptables or smth
local machine being my vps :S
it worked on from my vps
Can i use jinja syntax without importing django or flask
@native tide ye
oh
jinja2 library has a render method somewhere
so it responded
to itself
like i have a list and i want to display it in my html files one by one
ye you can
but what should i do in my python in order to do that
cuz the list is in my py file
there's examples on that page ^^
So that probably means you've got a firewall, no biggie
but, with that, we can confirm that you can run a flask app
now, try it exactly the same but with your normal app instead
You figure it out?
lol
ok so.. i just need to link it with apache now
right?
cuz i think thats where this error comes in
this is in sites-enabled
and is enabled
wait
ok so
WSGIScriptAlias / /home/crazygmr101/ansura/website/ansurasite.wsgi
i now know it's probs this line
should this be main.py?
yes
welp. that 404's too =/
Check your apache log file
oh. yea.
im.. dum
xD
Anyone here used the Pyramid framework? How did you like it?
error.log shows nothing
nothing recent anyway
access.log shows a bunch of 404's
hm
well,
odd
but yet it knows enough about the / route to load all the resources
There's probably a wsig error page
but also, here's the example config:
<VirtualHost *:80>
ServerName www.example.com
ServerAlias example.com
ServerAdmin webmaster@example.com
DocumentRoot /usr/local/www/documents
<Directory /usr/local/www/documents>
<IfVersion < 2.4>
Order allow,deny
Allow from all
</IfVersion>
<IfVersion >= 2.4>
Require all granted
</IfVersion>
</Directory>
WSGIScriptAlias /myapp /usr/local/www/wsgi-scripts/myapp.wsgi
<Directory /usr/local/www/wsgi-scripts>
<IfVersion < 2.4>
Order allow,deny
Allow from all
</IfVersion>
<IfVersion >= 2.4>
Require all granted
</IfVersion>
</Directory>
</VirtualHost>
which is significantly differnt than yours
well their docroot is different, and their app is in a diff place
Or for separate process:
<VirtualHost *:80>
ServerName www.example.com
ServerAlias example.com
ServerAdmin webmaster@example.com
DocumentRoot /usr/local/www/documents
Alias /robots.txt /usr/local/www/documents/robots.txt
Alias /favicon.ico /usr/local/www/documents/favicon.ico
Alias /media/ /usr/local/www/documents/media/
<Directory /usr/local/www/documents>
<IfVersion < 2.4>
Order allow,deny
Allow from all
</IfVersion>
<IfVersion >= 2.4>
Require all granted
</IfVersion>
</Directory>
WSGIDaemonProcess example.com processes=2 threads=15 display-name=%{GROUP}
WSGIProcessGroup example.com
WSGIScriptAlias / /usr/local/www/wsgi-scripts/myapp.wsgi
<Directory /usr/local/www/wsgi-scripts>
<IfVersion < 2.4>
Order allow,deny
Allow from all
</IfVersion>
<IfVersion >= 2.4>
Require all granted
</IfVersion>
</Directory>
</VirtualHost>
i dont need the ifversion cuz ik i have above 2.4
<VirtualHost *:80>
ServerAdmin webmaster@localhost
ServerName ansura.xyz
ServerAlias www.ansura.xyz
WSGIDaemonProcess ansurasite user=crazygmr101 group=crazygmr101 threads=5
WSGIScriptAlias / /home/crazygmr101/ansura/website/main.py
<Directory /home/crazygmr101/ansura/website>
WSGIProcessGroup ansurasite
WSGIApplicationGroup %{GLOBAL}
Require all granted
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
RewriteEngine on
RewriteCond %{SERVER_NAME} =ansura.xyz [OR]
RewriteCond %{SERVER_NAME} =www.ansura.xyz
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
</VirtualHost>
hm
I can see it's been starting btu I don't see wsgi starting, so are you sure the config is even running?
Put something invalid in it
ok
crash is a personal favorite
apache errors
i just put akjhdashdaskjdhasdaskjdhkasdkhaskjdashjkdhashdasjdhasjdhsajd in it
i have app when i use discord oauth2 and flask but how i can stop flask on redirect to redirect_uri ?https://pastebin.com/RbfK4p7A
What's the apache error log say?
invalid command
ok, so it is loading
ye
Is there an error log for wsgi itself somewhere
maybe /var/wsgi?
/var/apache/wsgi?
could check
according to the interwebs the best option is to set apache's log level to info
When using mod_wsgi, unless you or the web framework you are using takes specific action to catch exceptions and present the details in an alternate manner, the only place that details of uncaught exceptions will be recorded is in the Apache error log files. The Apache error log files are therefore your prime source of information when things go wrong.
yeah do that ;-;
huh.
it started the process
o h
ok so
hm
how do i make it never ever look for a file and always use flask
or do i just change my docroot to the flask dir
Try jsut removing the wrapping directory directive..
hm oki
but wait
thats not the dir it's erroring on
oh.
ok
so
i made /var/www/html/ansura/
if i remove the <directory> in site-available/ansura.conf
apache errors
I wish I knew apache better
im just trying to figure out where it's referencing that dir
and i mean i bet you know a ton more than me 
oh.
h u h
Ha.
lmao
hm.
Just change the ServerName and Alias in that section to localhost and you should be fine
In your last screenshot about apache conf
alr
The one pointing to /var/www
It's just ignoring your other wsgi vhost file cause both are pointing to same domain
It's autorewriting
Apache may need a DocumentRoot, iirc
well thats my new https config
Oh right, I didn't even see the wsgi vhost is only on port 80
You should put your old :80 on :443, and your :80 should just be the rewrite
so.. no http at all?
http only to redirect to https
Yea
hello i have a question realted to django
is this what i need?
can someone help pleae
just ask.
servernames on left are wrong
Change localhost back to your tld
yes
how can i make a link inside of a page
of an app
on django
path('string:slug/',views.article_detail)
i have this
anything else?
Hmm I see the file on the left was generated by letsencrypt ?
i want, only 1 header object.. and client must not have ADD HEADE function ...
of course... what about your question
OOP
how can i make a link inside of a page
of an app
on django
path('string:slug/',views.article_detail)
i have this
Ah nice @native tide I was wondering where the instructions for the keyfile were
Progress!
ok error logs it is

i'm not sure if this is the right way of doing it
@opal robin Give your url a name, then in a template you do <a href="{% url 'your_url_name' %}">Click</a>
@bleak bobcat i'm actually trying to do sth like this when i type localhost/parent/child i want it to show
so parent is the name of the app
than i want to make another link insinde views to point to child
its pointed at python2 not python3
aaaa
so i need to point... what?
noooo
so what am i pointing?
and uh
no
the vps is for discord bots so like
they all use the same packages anyway
See WSGIPythonHome
yes
In WSGIDaemonProcess directive
how do i disable ADD HEADER+ function? i want only 1 object in ... if there is 1 object (turn off add function) just how?
there? https://modwsgi.readthedocs.io/en/develop/configuration-directives/WSGIPythonHome.html doesnt give much more info
oop
nope
apache does not like that
Hmm, question, do you have libapache2-mod-wsgi-py3 or libapache2-mod-wsgi installed ? ๐
hm
(assuming debian based)
It should use the right python without you needing to specify it then

its ok, install the py3 one now
oh
i restarted
and it's hanging
thats new
ok now it's missing packages
wait
excuse me

am confused
this - i'm so close
it's trying
):
ohh
can i just symlink python3 to python3.7
cuz thats why
use pip3, not pip
i used pip thru python3.7
Is that why ? Isn't python3 already linking to python3.7 ?
3.6 i think
update-alternatives?
Yup
add python3 at the end
update-alternatives --install /usr/bin/python3 python /usr/bin/python3.7 2
use pip3, not pip
but yea i always use python3.7 and python3.7 -m pip directly
o alr
Yea use python3 instead of just python for the second one
Oh right
yea...My bad, command I gave you was for adding python3 as an alternative to python....
update-alternatives --remove python /usr/bin/python3 and update-alternatives --remove python /usr/bin/python3.7
o
ok
and the command i just sent?
that'll get py2 working right
update-alternatives --install /usr/bin/python python /usr/bin/python2.7 2
then
update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.7 2
?
yea
That just installed those as alternatives, check that the bin is actually using them ^^
@native tide got it, thank you!!
i mean ig i can but like
why is it happening with flask all of a sudden
i've always just used globals
I don't know :/ I'm mostly a uwsgi + django guy
well.. can i move this to a venv without changing the dir it's in?
or is that not a thing
You can but you'll need to specify your venv path in apache
I'll be available to help more if you want in a few hours, gotta work rn ๐ฆ
ah
oki
well ask me if i figure it out in a few hours then ;p
hf at work
it's still using py3.6 ):
why am i getting an error
can't you use operators in jinja2?
Hello {{name}}!
i like your lastname "{{last_name}}"
you enter a bar...
{%if {{age}} > 18 %}
You are old enough to enter the bar ({{age}})>
{%elif {{age}} < 0%}
You are not even born yet. Scram!!
{%else%}
You are not old enough ({{age}})
{%endif%}
Now i shall display your pets
{%if len(pets) == 0%}
You have no pets
{%elif len(pets) <=2%}
You didn't enter three or more pets so I ain't displaying anything</p>
{%else%}
{%for i in pets.split() %}
i
{%endfor%}
{%endif%}```
File "app.py", line 6, in <module>
template = env.get_template('mad_libs.txt')
File "C:\Users\Angelo Hoft\.virtualenvs\jinja_example-CHyGP6N2\lib\site-packages\jinja2\environment.py", line 883, in get_template
return self._load_template(name, self.make_globals(globals))
File "C:\Users\Angelo Hoft\.virtualenvs\jinja_example-CHyGP6N2\lib\site-packages\jinja2\environment.py", line 857, in _load_template
template = self.loader.load(self, name, globals)
File "C:\Users\Angelo Hoft\.virtualenvs\jinja_example-CHyGP6N2\lib\site-packages\jinja2\loaders.py", line 127, in load
code = environment.compile(source, name, filename)
File "C:\Users\Angelo Hoft\.virtualenvs\jinja_example-CHyGP6N2\lib\site-packages\jinja2\environment.py", line 638, in compile
self.handle_exception(source=source_hint)
File "C:\Users\Angelo Hoft\.virtualenvs\jinja_example-CHyGP6N2\lib\site-packages\jinja2\environment.py", line 832, in handle_exception
reraise(*rewrite_traceback_stack(source=source))
File "C:\Users\Angelo Hoft\.virtualenvs\jinja_example-CHyGP6N2\lib\site-packages\jinja2\_compat.py", line 28, in reraise
raise value.with_traceback(tb)
File "templates\mad_libs.txt", line 5, in template
{%if {{age}} > 18 %}
jinja2.exceptions.TemplateSyntaxError: expected token ':', got '}'
Remove the {{ }} around your variables when you're already inside a {% %}
YES
:D
@bleak bobcat @native root ty both!!!! 
also my error pages are da best :3
what was the problem?
every. single. thing.
hahah
:D
did you create an env after all?
no
i just ended up installing the packages in py3.6
lmao, I see..anyway, the effort paid off (I think)
well
i just need to debug a few things
but yes
:>
hf then ๐
yea just python complaining about a key that should be there
but i mean idek why i'm using an .env for my token
the repo is private
so you can't use the len function in jinja?
Yes and no. You can't use it like you'd use it in python, you gotta use a filter :
{% some_var|length > 0 %}
Hey
Can anyone suggest me some sublime packages for html, css and java
There are a lot and I cannot choose
Don't know much about sublime but emmet is a must have for me on any editor/IDE
Then I can't really help more, I haven't used sublime for a few years
Can I use flask_mysqldb without route, in normal function?
bcs I getting error in normal function, without route connection is None
Hi, I've finished a tutorial yesterday about making a blog-like website in Flask+Python with SQLite3, but now I want to improve and start using PostgreSQL. But I can't find anything that could help me from the beginning. I think I would just need to modify this part of the code where I declare what db I use and connecting?
app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///posts.db'
db = SQLAlchemy(app)
db = SQLAlchemy(app) ```
app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///posts.db' needs to be app.config['SQLALCHEMY_DATABASE_URI'] = 'postgresql://user:password@host:port
Other things are okay
(host and port would be like 127.0.0.1:1234 based on your database settings in case you didn't know)
Btw you need to install some libraries
Like psycopg2
Hello... I have a dash web app i'd like to deploy in my network via my own windows servers. Can anyone source me some good resources on how to do such thing? Thanks in advance.
@native tide you can't use operators in flask
How do i use the zip function in jinja2?
idk
i learned yesterday you cant use operators
bs imo
๐ซ
you can do other things
If I am listing all future events like so:
future_events = all_events.filter(start_time__gte=today).order_by('start_time')
Is there a way to also include dates that do not have a date set? I don't want past dates, but I do want to include "open" events where dates have not been selected.
When approaching a new site, what order would you guys recommend starting from? (Idea, Backend, frontend, design, desired features...). I'm looking into making my first site (touch-typing practice site) and am thinking that the best approach would be to start with the design/features so that I know what I'll need to code.
good idea
get some organization first before you start banging away at the keyboard like a maniac so you don't waste time 
so im using a gradient for my background with 3 colors
but for some reason when i resize the screen the background breaks into seperate colors
how can i fix this in css
?
no
how r u doing it then?
nvm i am
body {
background-image: linear-gradient(to bottom, rgba(225, 125, 57, 0.57), rgba(255, 131, 59, 0.95), rgba(255, 212, 0, 0.67));
background-position: center;
background-repeat: repeat;
background-size: cover;
padding: 0;
margin: 0;
}
you shouldnt need those backgroud pos, repeat and size bits
but you might need to set the height and width to screen size
but it breaks
if u resize the screen
i dont think taking those out wud do anything
if you quickly copy:
background: linear-gradient(150deg, #E1542A 15%, #9900FF 100%); and use that
and resize
does it still do the same thing
i use pycharm
how can i use python operators in flask
example
{% if guild['permissions'] and 0x20 == 0x20 %}
That's Jinja2
or instead of and you can use &
oh
still though
what's this 0x20 == 0x20 and what's your question specifically? what operator do you want to use
and or &
and i get an error jinja2.exceptions.TemplateSyntaxError: expected token 'end of statement block', got 'x20'
that
i know the code works in python
but jinjas lack of operators
and and or are correct in Jinja2
no
do you have an {% endif %} block ?
yes ofc
run this in your cmd prompt:
if 104189504 and 0x20 == 0x20:
print("yess")
else:
print("nooo")
then run it in jinja
why would I do that?
im just trying to prove to you its a jinja issue
andandorare correct in Jinja2
@native tide ^^^this is false
Integrate your service with Discord โ whether it's a bot or a game or whatever your wildest imagination can come up with.
thats the link ^
of what im trying to do basically
Go on their docs then
and read it for yourself
dude
what the fuck did you think i did
(permissions & 0x40) == 0x40 # True
(permissions & 0x800) == 0x800 # True
`
you dont think i read there docs
For if statements, for filtering, and if expressions, it can be useful to combine multiple expressions:
and
Return true if the left and the right operand are true.
or
Return true if the left or the right operand are true.
i already know
I m done helping here, have a good one
this is false bud
you can literally test it for yourself
0x20 == 0x20 stupid and it doesn't work like that in jinja2. Is that a hex?
Permissions are stored within a 53-bit integer and are calculated using bitwise operations. The total permissions integer can be determined by ORing together each individual value, and flags can be checked using AND operations.
or bits
bits
0x20 == manage_guild permission via discord
MANAGE_GUILD * 0x00000020 Allows management and editing of the guild
an example is
are you referring to the bitwise operators and not logical ones?
when you said
and and or
logic ones
then what I sent you is correct
try this example print(104189504 and 0x20 == 0x20) in python env and jinja
no, its not
literally try it for yourself
I get true
,which is expected
yes
now run
{% if 104189504 and 0x20 == 0x20 %}
in jinja
you will get jinja2.exceptions.TemplateSyntaxError: expected token 'end of statement block', got 'x20'
because jinja thinks x20 is a variable name
try
0x20|int() == 0x20|int()
can you includ this 104189504
in what you told me to try
{% if 104189504 and 0x20|int() == 0x20|int()%}
same error
it doesn't render bits the way you think
why don't you do that check in python
and you do it in jinja
do you really need it there?
yes, i do
{% if 104189504 and 0x20|string() == 0x20|string()%}
okay
actually
same error
give me the traceback
and the whole if statement block
{% for guild in guilds %}
{% if 104189504 and 0x20|string() == 0x20|string() %}
<h2 class="trans_hovr" style="color: white;"><img alt="" style="height: 3.5%; width: 3.5%; border-radius: 50%; border: solid white; margin-right: 1%; filter: drop-shadow(-5px 5px 10px black); transition: " src="https://cdn.discordapp.com/icons/{{ guild['id'] }}/{{ guild['icon'] }}"/>{{ guild["name"] }}</h2>
{% endfor %}
{% endfor %}
you end for
twice
fuck
instead of string
put
{% if 104189504 and 0x20|int(base=2) == 0x20|int(base=2)%}
traceback:
https://pastebin.com/61NafJxL
from when you asked
Update the code as I told you
yep
works?
no
same error
jinja2.exceptions.TemplateSyntaxError: expected token 'end of statement block', got 'x20'
send me the block again
{% for guild in guilds %}
{% if 104189504 and 0x20|int(base=2) == 0x20|int(base=2) %}
<h2 class="trans_hovr" style="color: white;"><img alt="" style="height: 3.5%; width: 3.5%; border-radius: 50%; border: solid white; margin-right: 1%; filter: drop-shadow(-5px 5px 10px black); transition: " src="https://cdn.discordapp.com/icons/{{ guild['id'] }}/{{ guild['icon'] }}"/>{{ guild["name"] }}</h2>
{% endif %}
{% endfor %}
ok
try
{% if 104189504 and '0x20'|int(base=2) == '0x20'|int(base=2)%}
ok
looks like its working
ok
hm
check further for yourself
thanks
@native tide actually
i dont think it works
as it shows all my guilds
because that condition you sent me is true all the time
exactly
it shouldnt be always true
then modify it
not possible
if i wanted a statemnet that was always true i wouldve done something 1000000000000000000x easier
whhenever i resize my screen
the footer breaks
is there any way to fix that>
?
Anyone have a good method for creating dynamic fields in flask? I'm able to use fieldlist to generate additional fields but I'd like to add a button so that users can add and remove fields like in this gif.
Hi guys, I'm trying to send a GET request to this link: https://www.finishline.com/store/product/mens-nike-air-max-axis-casual-shoes/prod2776399?styleId=AA2146&colorId=009 but it keeps returning Response <403>. I have tried using proxies and different headers but cannot seem to get a 200 response. If anyone can help me figure out what seems to be the problem I'd really appreciate it!
Thats the code for forbidden requests?
It is. Probably the site employs bot detection mechanisms
Use browser's network monitor to see the requests the site makes to the server when it is loaded
I think it is not allowed to talk about it in this server
!rule 5
5. Do not provide or request help on projects that may break laws, breach terms of services, be considered malicious/inappropriate or be for graded coursework/exams.
I posted this in #databases and have had crickets, so trying here.
https://www.youtube.com/watch?v=CSHx6eCkmv0
I am learning Flask by following Corey Schafer's Flask Tutorial and am having trouble writing the newly 'registered users' to my sqlitedb. The SQLite DB file is created, I can register a user, and no traceback error appears. specifically, my error varies from the video tutorial when registered user is not appearing in the DB like in 9:58. instead, I receive a None value.
the question: why isn't the newly registered user not appearing in the SQLite db?
In this Python Flask Tutorial, we will be learning how to add users to our database. We will then create an authentication system so that users can log in and log out of our application. We will be using the flask-bcrypt and flask-login extensions to help us with this. Let's g...
@icy wasp you'll need to provide some kind of code to get help. Put it on pastebin or something and link here.
@native tide great. Your website looks very well done. Could you provide some guidance on my code?
@icy wasp sorry, I was AFK for a bit. What IDE are you using?
funny you ask haha...I currently have python, IDLE, PyCharm, VS studio (just downloaded today), and VS code (just downloaded today); I am trying to decide which I should remove as I code in Python and now JavaScript. so I'll take anyone's input including yours haha
to answer your question, I run on PyCharm @vivid rose
@icy wasp I'm not to familiar with pycharm but in vscode you can use the debug tool. Set a breakpoint just before the DB commands (ideally right when you set the user_ variable) and then look through what all your variables are set as.
(You set a breakpoint by clicking to the left of the line number)
Can do same in PyCharm but havenโt run my flask app - have only ran through the terminal. Thank you, nevertheless. Will do it tomorrow and update you. ๐๐ฟ @vivid rose
@icy wasp sounds good. If you want to see a good example of stuff working check out flask-base on GitHub. They have user managment and everything. I based my first project of of it.
https://github.com/SelfhostedPro/Yacht
Hey guys, my django app's self.request.user become Anonymous after redirected from another domain.
is it possible to wait until session load?
LoginRequiredMixin can not detect user is authorized hence it became anonymous. i guess
Hey all. Im having trouble with the code below.
from sanic import Sanic
from sanic.response import json
from sanic.websocket import WebSocketCommonProtocol
app = Sanic("NoNameNotes WS")
app.config.WEBSOCKET_MAX_SIZE = 2 ** 20
app.config.WEBSOCKET_MAX_QUEUE = 32
app.config.WEBSOCKET_READ_LIMIT = 2 ** 16
app.config.WEBSOCKET_WRITE_LIMIT = 2 ** 16
@app.websocket('/feed')
async def feed(request, ws):
while True:
data = 'Hello!'
print("Sending: "+data)
await ws.send(data)
data = await ws.recv()
print("Got: "+data)
if __name__ == "__main__":
app.run(host='0.0.0.0', port='25563', protocol=WebSocketCommonProtocol)
I get the error
Unhandled exception in event loop
Traceback (most recent call last):
File "uvloop/handles/streamserver.pyx", line 143, in uvloop.loop.__uv_streamserver_on_listen
File "uvloop/handles/streamserver.pyx", line 67, in uvloop.loop.UVStreamServer._on_listen
TypeError: __init__() got an unexpected keyword argument 'connections'```
I use nuxt setup for the frontend. The config is like so:
And my /test route (on the frontend) code is this
<template>
<section class="section is-large">
{{ messageRxd }}
<button @click.stop="getMessage">
Test
</button>
</section>
</template>
<script>
export default {
data() {
return {
messageRxd: ''
}
},
mounted() {
this.socket = this.$nuxtSocket({
name: 'main',
channel: '/feed',
reconnection: false
})
},
methods: {
getMessage() {
this.socket.emit('getMessage', { id: 'abc123' }, (resp) => {
this.messageRxd = resp
})
}
}
}
</script>
<style>
</style>```
Hello guys.
I have a basic back end. I'm simply using flask, gunicorn and ngrok. Say I got 1000 requests at the same time.
What should I do? It would be good if I could accept these requests one by one or let's say two by two, and keep the other requests wait.
What do I need to research? Which technology/tool? Thanks.
they pretty much work like that anyway
they just wait
Flask is sync so it litterally can only do one request at a time per process
Are you sure? I'm going to test this
providing the timeout doesnt expire normally yes
@native tide just http requests is fine
Is it possible to send data from flask to discord.py and from discord.py to flaks?
Yes it is as well
How?
Oh like the html forms work
But how can flask send data to discord.py?
And if i use get then anybody can get the data
I am trying to read and print the messages in websocket of https://www.csgoroll.com/en/roll but i am not able to print anything, i have wrote this piece of code and not able to figure out where am i wrong, i am sending wrong frames or what. I have used this library https://pypi.org/project/websocket_client/
can someone help me to figure out where am i wrong, i am not able to figure it out 
What things should one know to become a stack developer
How can i send data from flask to discord.py
I mean post data to a python program thats not flask
@rustic pebble are you good at python (specifically in using socketio)
@coral raven Python, (html, css, javascript) or just bootstrap, flask to handle endpoints, jinja for templating, SQL.
I think i said most of the things to start with
@coral raven Or follow this dudes guide, its pretty helpfull
In this Python Flask Tutorial, we will be learning how to get started using the Flask framework. We will install the necessary packages and get a basic Hello World Application running in our browser. Let's get started...
The code for this series can be found at:
https://githu...
@tardy trellis I know django,html and css
@coral raven Then what do you need
And sql too
No
Also SQL of course
What is bootstrap
CSS framework
i mean its good to know it
Sqlite
An sql engine
Bootstrap is pretty old now
it still gets used but there are others out there
which dont cause issues if people dont have js enabled
Its the same as Postgre and Mysql
Thats the one i tried first
and found it very easy
to start with
Bootstrap i mean
Its a runtime environment
that runs javascript
express is a framework
but its has the same purpose like django
Its for the back end
@unique hill I am proficient, havenโt really used sockets for more than just simple chat
Hey guys, having a problem I'm hoping someone could help with?
How can i receive requests on a normal python program
New to discord (and to python) so hoping this is the right place to post
Trying to check a database to ensure a username does not already exist before allowing a user to register, but getting a runtime error for missing value for placeholder (:username). But I thought I was giving it a value? Here's the code:
# Checks to see if username exists already, if so return apology
usernamecheck = db.execute('SELECT EXISTS(SELECT * FROM users WHERE username=:uname)', uname=username)
if not usernamecheck:
return apology("Username already exists.")
how can i make a countdown using flask and redirects after the countdown ends
Where i should ask django related question?
Where i should ask django related question?
@last abyss here
What one text editor can I use with extensions for stack development
you can use Sublime text or Visual Studio Code, these 2 are ones i personally use
how can i make a countdown using flask and redirects after the countdown ends
is this possible or i should use js for that
You probably need some very basic JS yeah
@rustic pebble but can you help me
For alembic migrations, are there anyone else in here who likes to write them in plain sql?
fx.
somehash_added_users.py
added_users/upgrade.sql
added_users/downgrade.sql
Where the added_users.py just have two functions, that calls something like this:
def execute(bind, filename: str):
session = orm.Session(bind=bind)
file_path = pathlib.Path(f"migrations/versions/{filename}").absolute()
with open(file_path) as f:
sql_to_execute = f.read()
session.execute(sql_to_execute)
session.commit()
However I have yet to automate it further ๐คทโโ๏ธ
Does anyone have suggestions for sanitising user input in pymysql? I'd also like to know how for aiomysql but my use for that isn't web related as such
I'd suggest using an orm
?
Hi guys, I'm new. Could anyone help me where can I find beginner projects for python? I'm mainly want to use it for web. But all tutorials and pjocets I find is too complicated
Django's official documentation contains an easy to follow poll app tutorial
So
I want to communicate with my bot and my web application
so what I have so far is
import asyncio, datetime, random, websockets
import discord
from discord.ext import commands
TOKEN = ''
bot = commands.Bot(command_prefix=".", case_insensitive=True)
@bot.remove_command('help')
async def post_guilds(websocket, path):
guilds = []
for guild in bot.guilds:
guilds.append(guild.name)
await websocket.send(guilds)
@bot.event
async def on_ready():
start_server = websockets.serve(post_guilds, "127.0.0.1", 5678)
asyncio.get_event_loop().run_until_complete(start_server)
asyncio.get_event_loop().close()
bot.run(TOKEN)```
but I get the error
event loop is already running
what does this mean and how do I fix it
<!DOCTYPE html>
<html>
<head>
<title>WebSocket demo</title>
</head>
<body>
<script class="design">
var ws = new WebSocket("ws://127.0.0.1:5678/"),
messages = document.createElement('ul');
ws.onmessage = function (event) {
var messages = document.getElementsByTagName('ul')[0],
message = document.createElement('li'),
content = document.createTextNode(event.data);
message.appendChild(content);
messages.appendChild(message);
};
document.body.appendChild(messages);
</script>
</body>
</html>```
this is the html I use to preview it in the browser
Isn't it kinda strange to use async but then go ahead and append the results to an array? @native tide
can i use psycopg2 without the Sqlalchemy
@native tide a few things
- Dont run a webserver and a bot in the same process
- run_until_complete is blocking because its intended to start the event loop, it will block the entire bot with or without an error
- dont close the event loop you will fuck your bot
@mortal socket Yes? Just use it like a normal SQL driver?
ok
also @native tide @bot.remove_command('help') isnt a thing that exists
you will just nuke that function bellow it
@quick cargo Can you run 2 programs in the process ???
I though you could run only one
Or is it asynchronous
??
Well with what theyre trying todo no
you can run stuff with threading which can have two bits of blocking code running parallel but its not good to have a webserver and a discord bot running together
He should run as seperate systems
As different system processes ??
as in running them as two different programs
Yeah thats what i said
Run them in different processes
One in PID 1 and the other in PID 2, for example
Hey guys! I have a registration page. It has password confirmation as well. But the page doesnt actually check if passwords match
hey, is it possible to copy a 6 digit number from a website, like 123456 with selenium?
@deep grail I don't think anything is going wrong there, seems like you did just like:
https://blog.miguelgrinberg.com/post/the-flask-mega-tutorial-part-v-user-logins
It should work
Oh right
Thanks for the concern regardless ๐
No probs
hey, is it possible to copy a 6 digit number from a website, like 123456 with selenium?
@native tide I used regex along side python requests module for that type of task but it wasn't 6 digit, it was a phone number
regex huh?
No probs
mobile
got it! thanks
Hey, I got redirected to this channel from one of the help channels. This is my first question so I'll try to be as extensive as I can be, but if you need more information I'll do my best to give.
So, I'm a beginner learner, and have been following Programming with Mosh's video (/watch?v=_uQrJ0TkZlc). Toward the end of the course, he teaches us how to use the Django framework.
He recommends us to install Django 2.1, and we are working with Python 3. We have a project PyShop and an app for Products. We have set up the server and can log into the admin page. Up to this point I have double checked all the code and it is the same as shown in the video. I want to add a product to the table, but find myself with this error:
Exception Value: no such table: main.auth_user__old
I did a search online and found that either I downgrade SQLite or I update Django. I also tried doing the migrate step and runserver step again. (stackoverflow) Still same error message for me. Could anyone try helping me with this?
I suppose a fix could be that I rewrite all the code and start up the project again with the new version of Django, and would not take too long. but in the future, if this error were to come up again for a bigger project, it could be good to know if there is another solution
Why not update django ?
delete your database and try migrating again
I assume the database is the .sqlite3 file?
Yup
๐
Thank you ๐
no probleรน
fyi, when you're running django on production (live website instead of local) you shouldn't use the runserver (and probably shouldn't use sqlite either, but that's much less important)
Alright. Not sure which direction I'm heading with my learning of Python, and this video course gives an introduction in a few areas. Maybe I'll choose web development since this stuff seems really useful and fun
there is anyway to host flask app w db on github pages
no
is there a way of adding nodejs to a flask app?
why would you mix a JS runtime with python exactly? @magic scarab
prob hes running a discord js bot
and he needs some sort of communication between python and the bot
you wouldnt even do that tho
i dont get why people think having the webserver and bot on the same program is a good thing
no, i want to when i type in the search input for results to appear directly on the dropdown and not to redirect to a /search or idk
and the only way that comes to my mind is with react but i need the mongodb package
python has a mongodb package tho @magic scarab
hey guys, for my project i want to take data collected by the USGS, convert it into a heatmap, then update a preexisting heatmap on a website of mine. I'm using leaflet.js for my map, but i'm wondering if it's possible if i can update a map like that regularly?
How do I reverse a URL in django without knowing the app's namespace ahead of time?
Hello guys!
I finished learning all the basics there is in python, created some projects
Not too difficult
What should I do now
All projects seem difficult to me
I want to get into web dev( I know HTML)
so build a web site
You can look into flask
requests and beautifulsoup are some things to mess around with.
yes, just like that. Spend a few hours with a tutorial and write "hello world" -- a site that has a single static page.
mess with that.
So I should focus on flask, beautifulsoup, requests..
Rest all modules are not that umportant right?
then maybe have a couple pages. Then maybe have some computed pages. Then have some state. Then try deploying the code to a Real Web Server Host. There's tons to learn,but you can edge into it all gradually.
I wouldn't think you'd need beautifulsoup unless your web site's purpose in life is to scrape other web sites.
meh fun to mess around with. though yes, practically limited.
What other skills/languages are required to get into web development
bit of Unix sysadmin.
fair amount of HTML CSS JS
but don't wait to learn those; learn them as you go, messily.
at least that's what I did ๐
disclaimer: I am not a full-stack developer
taking notes, how well did it go
I studied html before everything and I think I should not have done that, could have done that with python definitely
doesn't sound dangerous to me
If you're interested in Django web development, I highly recommend the book "Django 3 by Example". You get introduced to LOTS of Django techinques and related softwares (postgresql, celery, redis, memcached, uwsgi, nginx, channels, rabbitmq, etc). I'm on the last chapter, where it walks you through getting your project ready for production, and its been amazing. Learned how to do a bit of everything, and it'll be a great reference as I begin making my first website (Touch Typing practice)
You'll learn a big chunk of HTML just from following along, but I've also been dedicating a bit of time to a html/css book. Got a JS book (elequent JavaScript) that I'm also studying from which has rounded everything out.
How much did you spend on between learning python basics to getting into django
I worked through 2 books (Python Crash Course and then Automate the Boring Stuff). However, if you've learned what classes are and how they work, the you're ready for Django.
Or just go directly to endgame and skip django.
The book assumes you've at-least done the official beginners tutorial from the Django website.
writhing monoliths in 2020. 
If you're willing to dedicate a day, I highly recommend learning Dockers. Wish I would've started using them years ago. Life has been so much better, especially since I'm on windows and sometimes have trouble installing programs.
Yes sir will do
i don't understand what's difference between django and django rest framework
could someone explain to me ?
rest framework for api i think.
Yes, the rest framework is like a DLC for Django. Its a bunch of tools that make it easier to add an API (Used by things like mobile apps or external sites). However, it's not required to run a Django site.
I like that a DLC for Django hahah
what you think guys, which is the easiest way to Translate pages in Django .,. i know i18n ,.. just looking for another way.
{% if error %}
{% import time as t %}
<div class="alert alert-danger" role="alert" id="err">{{ error }}</div>
{% endif %}
{% t.sleep(3) %}
jinja2.exceptions.TemplateSyntaxError: Encountered unknown tag 't'. Jinja was looking for the following tags: 'endblock'. The innermost block that needs to be closed is 'block
help
i think last line is not correct... use {{ t.sleep(3) }}
and you have not endblock in template ... as error code said
Hello everybody, is it possible to post a photo on Instagram with Python?
Hi, I am using .matchAll on desktop and it works fine yet on mobile it says the function doesnt exist yet being confirmed to be supported on MDN. Is it a different function or something?
it doesnt
It doesnt, look through the adjacent divs; it is there.
In Django docs -- "
Metaย inheritance
When an abstract base class is created, Django makes anyย Metaย inner class you declared in the base class available as an attribute.ย
"
What does that "available as an attribute. " mean?
@ripe hemlockhm, thanks.
Hey! How difficult is getting authentication working in Flask?
using django-filter - how do I filter by selecting multiple values for example say I want to find blog posts by two authors
Also does anyone have the link to the django discord?
@native tide it fairly easy, flask's Auth is easier imo
@twilit zenith Easier than djangos?
@stray coral python model_name.objects.filter(author__in=['author_1', 'author_2'])
thank you
I know it's not python, but I can't get what I want with Jinja atm. Problem with whitespaces in a for loop... I try to follow https://svn.python.org/projects/external/Jinja-1.1/docs/build/escaping.html
{% for tag in pagedata['tags'] -%}
{{ tag['name'] }}
({{ tag['number'] }})
{{ ", " if not loop.last }}
{%- endfor %}
I still get a whitespace
how do I get rid of this?
I'm trying to add tags to my bookmark app...
Oh yeah, and how should I do always have tag (number) on the same line?
maybe using a html span element with nowrap, i guess
@native tide yeah Flask is much simpler, if you aren't building something big, I would suggest using flask instead of Django.
@winter void When you make a new line, HTML interprets that as a whitespace (not a full linebreak, just a space). Is that what you meant?
Can someone explain me this?
Sounds like it's telling you that you wont get a list of MyPerson objects directly. You'll always get a querysey object that contains MyPerson objects.
I didn't understand from the point "The whole point of proxy....."
Whats the simplest way to send data from flask to discord.py
anyone one know a website were i can watch the walking dead for free
Selenium keeps on having this problem when I try to run the chrome webdriver: ```SessionNotCreatedException('session not created: This version of ChromeDriver only supports Chrome version 81', None, None)
I have tried all the versions of the webdriver chrome has on their site, nothing
@vagrant dock once you find a legal source you can use this to get it - enjoy https://github.com/gallexis/pytorrent
@frail lark what version of Chrome are you driving?
No problem @frail lark , what was the problem? Just a mismatch in versions?
yeah, just needed to redownload an update
@spice bough get what
@vagrant dock the tv show you asked for
@spice bough oh ok what u mean legal source i wanted it for free lol
@vagrant dock Check out this page http://investor.amctheatres.com/executive-officers-and-board-of-directors maybe someone on there could hook you up
View the Executive Officers and Board of Directors lists, including their titles and biographies.
Hello, I am having a problem regarding selenium. Is there anybody that can help?
Iโve used selenium for a couple of things, what are you trying to do
Did you try selenium IDE and see how it chooses it?
What does that mean?
There's a noob version of Selenium that works as a browser extension
It can record your activity and turn it into a series of commands. From that you might discover how to access that button
Thanks ill try it
@dull sable let us know if it works
@dull sable What you're trying to do both breaks rule-5 here (by breaking the google TOS), and is a giant pain in the ass compared to just using Google's translation API
What is google's translation API
Literally the only thing left in my code is needing to press that button
5. Do not provide or request help on projects that may break laws, breach terms of services, be considered malicious/inappropriate or be for graded coursework/exams.
Does it actually break the TOS?
I never would have thought xD
they provide APIs for literally everything. There's really not much reason to want to scrape from them except cheapness
That's fair
Finished my Django textbook and started my first site. Scary stuff not having someone hold my hand. Luckily I spent the last few days writing up a development roadmap, so I got an idea of what I should be doing first. Here we go!
gl :-)
Letโs say user saves jpg at 75% quality, then uploads to your website which saves it at 75% quality. That user isnโt gonna be pleased with the result?
Hi guys, quick question. Im using flask to make an app and I have several buttons. Each button has its own form with the form action each sending to a different URL which I then create a route for and then execute code based on that (Ill attach SS). My question would be is that a "correct" or efficient way of doing it? Or would a better way to create one from, and each button sends a different value and then have 1 app route to listen and have an IF statement to differentiate between values
I dont know if that makes sense so ill send a SS of the codee
if you see what I mean i have a different route for each button, and as my app expands I will have many routes for every button, not sure if that is a weird/inefficient way of doing it
Hi, I am using django-filters and want to paginate the filtered result, however, when I go to the next page , the filtering breaks and unfiltered data is displayed. Here is my code: https://dpaste.org/cZuC
At Sam: I'm a noob, but, to avoid code duplication, I would go for a single route. Also, perhaps a dictionary could be used, instead of many if statements.
Made a REST API and want to validate a purchase and create virtual machines/containers with it. I have no clue on how to approach this. Someone got any tips?
Hey I want to make a really simple web framework for APIs. Where should I get started?
Hello, I want to use selenium to get the part of the code that says
"hallo", but so far i am not sure what is the right command
i tried getting the element ID and the doing element.text() but that returns the error message "unicode object is not callable"
Hi, I am using django-filters and specifically DateFromToRangeFilter but it is not working. My code : https://dpaste.org/h2oZ
Why is there filter.forms|crispy
Which framework is better for an API endpoint, Flask or Django?
@azure rune try using fastapi
Async frameworks will probably lend themselves to api's better because of the high throughput
Does anyone know if it's possible to inject code or strings to extract information a user shouldn't have access to into url query strings that are defined by changing script variables in the browser's console or by similar methods? User will not have a text form btw.
Are there any trending websocket libraries now-a-days that would allow me use SSL and a back-end event loop?
I used to use https://github.com/Pithikos/python-websocket-server but they don't support SSL
I'm looking to connect players together randomly, in a tabletop RPG type session. 1 host and 4-5 players will connect together randomly to play a MUD-like game.
Have Django Channels gained any more traction?
Im not sure
I dont thing there is much support for it still because of how Django's worked itself
Worked itself in what sense?
It lends itself very well for things like Ecommerce stuff and smaller sites that dont require as much low level control as larger systems
along with those sorts of sites dont necessarily have as much use of websockets especially with Django which is still currently not async safe
which is where micro async frameworks tend to go ahead of Django because theyre more performant in that end
@ app.route("/dashboard", methods=["POST", "GET"])
def dashboard():
if "oauth2_token" in session:
logged_in = True
else:
logged_in = False
if request.method == "POST":
ban_reason = request.form['ban_reason']
sql = "INSERT INTO cb_718580065255948318 (ban_reason) VALUES (%s)"
val = (f"{ban_reason}")
cursor.execute(sql, val)
db.commit()
return redirect(url_for('dashboard'))
else:
return render_template("dashboard.html", logged_in=logged_in)
Error:
ReferenceError: weakly-referenced object no longer exists
any help will be nice ๐
nevermind, got it fixed
along with those sorts of sites dont necessarily have as much use of websockets especially with Django which is still currently not async safe
@quick cargo
Interesting. I used Django with a websocket library that worked really well. I basically just used Django for the web server and ORM, and just made the loop in the websocket while the python back-end did all the work.
Worked really well except that the websocket wasn't SSL so I'm looking for an alternative.
Hello, im getting a problem using the requests library.
When i use requests.get(url), i just dont get any response...
If i use requests.get(url, timeout=5)
I get the response after 5 sec and etc...
It looks like the function just return anything after the timeout
I also reaslize that in simple html pages, this problem doesnt occur
r = requests.get('http://www.google.com', timeout=5)
[print(key, value) for key, value in r.__dict__.items() if key!='_content']
b = requests.get("http://www.brainjar.com/java/host/test.html", timeout=5)
print("\n\n\nSecond Request", b.elapsed)```
i get
_content_consumed True
_next None
status_code 200
headers {'Date': 'Mon, 29 Jun 2020 22:49:08 GMT', 'Expires': '-1', 'Cache-Control': 'private, max-age=0', 'Content-Type': 'text/html; charset=ISO-8859-1', 'P3P': 'CP="This is not a P3P policy! See g.co/p3phelp for more info."', 'Content-Encoding': 'gzip', 'Server': 'gws', 'Content-Length': '5397', 'X-XSS-Protection': '0', 'X-Frame-Options': 'SAMEORIGIN', 'Set-Cookie': '1P_JAR=2020-06-29-22; expires=Wed, 29-Jul-2020 22:49:08 GMT; path=/; domain=.google.com; Secure, NID=204=D54suyp-J_USXnF-7VH7MZF6gIAybpdAZdaDyEPQIIMZ_qE-sP70T8p7uFhlfkFdzqzpPCUdtpQhXjH7EGjWTB6gxV7BxyGHMHfCVSWSZVTaas7iHHR3U5ulo48HLRIC_AoGBKxWNaqKyDf2s1sHFsjbkFCV23jEw1evPBgtYlo; expires=Tue, 29-Dec-2020 22:49:08 GMT; path=/; domain=.google.com; HttpOnly'}
raw <urllib3.response.HTTPResponse object at 0x7f1ad1cb80f0>
url http://www.google.com/
encoding ISO-8859-1
history []
reason OK
cookies <RequestsCookieJar[<Cookie 1P_JAR=2020-06-29-22 for .google.com/>, <Cookie NID=204=D54suyp-J_USXnF-7VH7MZF6gIAybpdAZdaDyEPQIIMZ_qE-sP70T8p7uFhlfkFdzqzpPCUdtpQhXjH7EGjWTB6gxV7BxyGHMHfCVSWSZVTaas7iHHR3U5ulo48HLRIC_AoGBKxWNaqKyDf2s1sHFsjbkFCV23jEw1evPBgtYlo for .google.com/>]>
elapsed 0:00:05.176726
request <PreparedRequest [GET]>
connection <requests.adapters.HTTPAdapter object at 0x7f1ad0e9c208>
Second Request 0:00:00.645876
[Finished in 15.6s]```
guys, anyone confortable with jquery that could give me a hand?
i want to make the following:
create table lines with data with an '+' button (& being able to delete it with a minus)
send the data from the tables to flask as a dict.
any tips?
@dull sable> i tried getting the element ID and the doing element.text() but that returns the error message "unicode object is not callable"
@dull sable did you encode the text to 'utf-8'?
Hello, im getting a problem using the requests library.
When i use requests.get(url), i just dont get any response...
If i use requests.get(url, timeout=5)
I get the response after 5 sec and etc...It looks like the function just return anything after the timeout
@frank nebula the page could load with JavaScript I like to .get() with selenium.
@frank nebula the page could load with JavaScript I like to .get() with selenium.
@icy wasp problem kinda solved! Im forcing my requests to be IPV4 and now works normally
its an input with a datepicker attached
@frank nebula awesome to hear. Didn't know that was a work around. Any idea what was the source of the problem?
but (settablefilter) doesn't run unless you type, selecting a date from the picker doesnt update it
I installed Ubuntu recently and ithink it some socket problem. I know nothing about networks and sockets, so i cant tell where is the problem or how to solve
Anyone knows how to embed pagination with ajax in flask?
Hey guys, so first I hover over the image and it goes large which is fine. But as soon as the cursor leaves the image, the image enlarged which I donโt want? Anyone know the reason why thanks
@shadow forum btw noticed your status, you shoud install the rich prescence plugin so if you dont want it to show "JetBrains IDE"
oop wrong channel
@frank nebula oh ok. gotcha. Good luck haha
is web development possible with just Html, Css, JavaScript and Django?
Yes
Technically web development is possible with only html...But that won't get you far
Yea, official documentation has a poll app tutorial
thx
Django has pretty complete docs on their website, I found this series helpful when I started out, though it is dated: https://www.youtube.com/watch?v=qgGIqRFvFFk&list=PL6gx4Cwl9DGBlmzzFcLgDhKTTfNLfX1IK
Facebook - https://www.facebook.com/TheNewBoston-464114846956315/
GitHub - https://github.com/buckyroberts
Google+ - https://plus.google.com/+BuckyRoberts
LinkedIn - https://www.linkedin.com/in/buckyroberts
reddit - https://www.reddit.com/r/thenewboston/
Support - https://www....
depending on the complexity of what you want to make, you might also like to look into something like flask; I find it requires less understanding upfront to be productive compared to Django
I'm looking at making a proper microservice, with either a REST API or event streams communications. For that I'll probably use some trivial libraries like Falcon or at most Flask.
However, since this is a proper production top knotch code, I need a resource to tell me what the best practices are, so that I don't reinvent the wheel.
So far everything I checked in any books about web development just briefly touch on this, with Hello World apps, and that's it.
How do I make it work with high demand? Where does asyncio best fit? How many gunicorn processes to start and why? What performance-related thoughts are also there? How do I write proper tests for it (what's the balance between feasibility and 100% code coverage)? How do I deploy it to the cloud properly? Which communication methods to use in which cases?
Did anyone encounter such a book, course, tutorial or anything? I know it probably won't be free, but this is really important for me.
@fair oriole The problem is that there is more than 1 best way for all of the questions you are asking and everything depends on everything. I also have not found any such resource that combines all these different subjects.
If deployments/performance questions are more of a means to an end I would recommend looking into serverless functions, maybe through a service like vercel) They have a fairly good deployment process baked into them and because of the serverless nature the scalability is really good. If you actually want to learn about all these things for the sake of learning, you will just have to read a bunch of resources and decide which you like the most I'm afraid.
As for application design and proper tests, I would seek out a place where you can get your code reviewed. the CS discord channel has a code-reviews section I believe. Many knowledgable people can and want to teach you how to improve your application, you just have to ask ๐
I was hoping for at least one interpretation of "best way" :)
But yeah, I saw serverless functions being used. The problem is that they get really expensive when you have sustained workloads, and in that case I'd be looking more towards Kubernetes.
I come from a data engineering background, and until now any python app needed to be clearly sequential. Whenever I need to do something in parallel I just create a swarm of threads that read from a task queue until an "end" message. This whole async thing has always eluded me, when I worked with JS, when it appeared in .NET, and now in Python. I know what it is and what it does, but I never got to properly work with it, and properly use it, and properly get book-quality explanation of why things are needed.
And now in an interview with a big company, I saw that user-event-driven back-end apps also have a way to interact with very low latency via event streams (Kafka), etc.
I have a long vacation before I join a new company that requires all that from me. I want to minimize my impostor syndrome once I get there, and I don't mind spending hours learning stuff that I'll need in order to be better than I was when I was offered the contract.
Alright, well here's my interpretation of the best way, maybe that will give you a place to start researching:
How do I make it work with high demand : The bottleneck in 95% of all cases with web-based applications in my experience is database transactions, generally very inefficient reads caused by some ORM magic. If you have high demand, make sure that your database interactions are as simple and minimal as possible. Ideally build your own ORM. Data processing bottlenecks are much less frequent that database issues
Where does async fit in: Honestly, anywhere where you are processing independent data. If you want to make async a little easier to deal with, it is best to work from pure functions (from functional programming) as it makes concurrency way more overseeable
What performance-related thoughts are also there: Generally, almost none. Readable code is way more important than performance. Tackle performance once it becomes a problem, not before.
How do I write proper tests for it: I recommend exploring tools like hypothesis and hypothesis-auto if you are dealing with input. As for coverage, I think good coverage is a reuslt of well-factored code. It is really easy to write a test for a pure function and really hard to write a test for stateful spaghetti. If you reduce the amount of stateful spaghetti by always factoring your code into as pure a state as possible, it will be easy to get good and reliable coverage
How do I deploy to the cloud properly: Terraform + gitlab CI/CD. If you need to manage servers, Infrastructure as code is invaluable. gitlab ci/cd is just neat in general.
That said, if you are already joining a new company, you will learn their best way soon enough. There will be plenty of experts there to help you out, so I would just nejoy your vacation if I were you ๐
Yeah, the part of Databases, and data flows, I got covered quite well, as that is where I'm one of the best in my field :D. Worked with Terraform, not so much with CI/CD but from looking at it before it seems quite simple.
I'll try to convince myself to write less stateful stuff.
Thanks! But I'll still be looking for good examples somewhere for what a high load microservice looks like.
Wish I could be of more help ๐ Good luck though!
@dense slate you could not use a webserver that supports SSL termination like NGINX?
I ran into an issue where the web socket wouldn't load with ssl enabled.
But it was because of that specific library
nginx would decrypt the message and proxypass to the websocket server
And the opposite too, encrypt it before sending to the client
Hello I am writing because I have problem with flask psycopg2 anyone have a second to help me ?
who can help me with my django error DMe if you can
What's the purpose of nginx?
Right now, I have a DNS record that points a subdomain to the ip address of my server.
my nginx config on the server is just passing port 80 to port 5000 all on localhost
However, every config I've seen online passes it to a domain name
@native tide nginx is a very optimized web server. It runs its own user, and can listen to port 80. Your user can't, for security reasons. Nginx can handle a lot of configuration. Even if in this case there isn't much config, if you want to add another site on the same server - you can with nginx. If you want (and definitely SHOULD) enable HTTPS, nginx can handle SSL. Do the site in Python, handle traffic with nginx.
is it appropriate for me to pass to localhost
because all configs I've seen online use a domain name
if you do it always on localhost then you don't need nginx at all
for development you don't need nginx
it's for production
my web server is being hosted on a different port, and all I want to do is have it accessible on port 80, as well as use https
what I did was just pass it to the web server on the localhost
Hello I am writing because I have problem with flask psycopg2 anyone have a second to help me ?
@weary blade BUMP
then nginx, 80 for http, 443 for https. But you should never run a site on port 80. Make port 80 always redirect to 443 instead.
events {
}
http {
server {
listen 80;
server_name localhost;
location / {
proxy_pass http://localhost:5000/;
}
}
}
this is my entire nginx config rn
I don't know if this is the correct way to do it
@weary blade BUMP
@weary blade voice your question in one of the available #help-* channels. And start with actually writing the problem, not asking for help :).
like #help-carrot which is now available
I have opened oxygen
then why are you still here
And nobody is reading that even
because you're impatient
be nice
me ?
as well as obnoxiously bumping your question in front of mine when I was in the process of being answered
but I guess that already goes with impatient
So why is it that when I see nginx configs online, they usually have a domain name as the server_name and proxy_pass?
@native tide you're being rude.
you want a good answer, take a help channel. Don't be mean to other members of the community.
Is it optimal to use WYSIWYG in your web app? The generated HTML is quite large
No, WYSIWYG is a terrible approach and frowned upon by actual front end devs
It might be usable for mock-ups
Mkay.. so it is better to use a pre-styled template for a post rather than letting wysiwyg generate the code for yourself.
Absolutely
If you're looking for good documentation on this stuff, I recommend Mozilla
documentation for?
HTML CSS and JavaScript
