#web-development
2 messages · Page 59 of 1
but at my company, we have a ton of APIs and web pages powered by Java backends
applets, what year is it?
🤮
my company LOVES Java
in fact, one small group in my division writes their microservices all in Java, rest of our group uses .Net Core
wait im kind of confused here
.NET is nice
so learning web development with python and java is bad?
javascript != java
^
web development is broken into two pieces, frontend which is code that runs in browser, the backend which is run on the server
oh ok
frontend is all HTML/CSS/Javascript
Kind of
and what are the backend options?
many
backend can be whatever you want to be, Java, Javascript, .Net, Python, Rust, Go to name a few
Every major language has an http framework
so is python good for this
final?
can be, yes
is it meant for web development?
its used ALOT
meant for, no, acceptable choice, yes
things like instagram, dropbox etc... all use python backends
ive to look for a web development course on udemy or something else
things like instagram, dropbox etc... all use python backends
@quick cargo instragram uses node probably
all major companies backends are probably in smattering of languages
Instagram runs on Django
depending on which group designed that microservice(s)
which is why you develop HTTP Microservices, then you don't have to give a crap about what a backend is written in
@quick cargo wow didn't know that
i dont think they use go anymore
last time they used Rust and Elixer
CF8, I'm sure they haven't convert 100% to Rust
apparently you work in corporate, you know how that goes
we will get to that microservice, you know, at some point
tbf its like some banks still using languages from 20 years ago or more
like we still have microservices we haven't converted from .Net Frameowrk -> .Net Core
COBOL
yeah lol
netflix runs on flask
and java
react + clustered node is bae
thanks a lot guys all my doubts have been cleared
if you are learning, Javascript is not bad language to start with
The Social Network inspired me on checking out web development
you can use it as both frontend and backend (shudder)
Javascript is not really beginner friendly it has a c-like syntax and loads of moving parts
as i have finished the python basics and stuff
Sure but after you get over it, it's swiss tool box web language
so wont it be crazy to start js another language immediately
Yea
I never properly watched a tutorial on javascript
I legit picked it up after learning python immediately
Sure, it's harder then python, but for web, I'd say if you wanted to learn a language, it's pretty much mandatory
and then I just expanded upon it
esp with whole "Full stack developer" trend going down
aka, let's get 2 for price of 1
huh
Just learn react-node and you can call yourself a fullstack dev
flask is based on python right
flask is python lol
Once you need it
One thing brings the other
When you get into the whole web development world you will need to learn the rest so you will be physically challenged to do so
kay
@gusty girder what do you exactly mean?
huh?
So after you learned python what area did you specialize in?
well somehow i stumbled upon discordpy bots
and spent some time on that
then i thought of building apps
Well I guess that counts as machine learn and AI
and tried learning kivy
built a really simple app which i have to convert to an apk
Err not gonna lie man your kind of all over the place 😬
Are you like very good in at least one of those areas?
Like good enough to make a whole YT tutorial on it
then ig interested in web dev and planned to make a personal website
Woah man let’s take it easy for a second 😅
im like multitasking lol
Be careful with that
like when i learn one thing i discover another thing and get interested on that
Normally people who multitask and try and learn 5 things at once don’t tend to do so well
ik
Unless of course you learn well like that
i just cant seem to stay and finish off one thing
recently i saw The Social Network and got interested in web development
That’s one thing a LOT of programmers say is the worst thing you can do
You should try and learn at least ONE thing and get very good at it after that you can move on
It’s almost like learning an instrument
kay
If I start playing trumpet and get into it
But then I find another instrument let’s say the sax
You start leave the trumpet for the sax
But then you leave the sax for the Clairinet
You get the point
But if you keep doing that you’ll never learn how to play one song on any instruments
Same thing goes with programming
I was like you before but thankfully I saw a video about biggest mistake a programmer make and I learned I should stick to on thing
So if you keep doing that with programming you’ll never learn how to create one program in any of the areas
yeah
I used to do the same thing when I was in 4th grade
wow you started coding in 4th?!
I learned 4 programming languages throughout middle school
Oh dang someone that”s actually my age 😂😂
I’m turnings 14 this year
Oh dang someone that”s actually my age 😂😂
ikr finally someone my age
Wait we should talk about this in #ot0-fear-of-python general
ok
hey guys is there a way to limit user like that he cant see some buttons or texts?
Use permission levels
What’s the JavaScript code?
I am trying to ignore a block when parsing a file with python-markdown. Anyone got an idea? I have tried writing an extension, but if I just echo the block back, markdown garbles it later.
If I parse with the other tool first, which puts out html, then markdown puts that inside a <pre> tag
@opal kelp It probably sends it twice due to your if logic
if (!data.error and data.title) will probably fix it
It is also bound to document click
why not just bind it to the click function of the button?
onlick='function()'
I also wouldn't use jquery.. write JS not jquery
...
here's a resource to help substitute jquery functions for vanilla js http://youmightnotneedjquery.com/
Examples of how to do common event, element, ajax and utility operations with plain javascript.
also jQuery is totally valid and tons of websites use it, there's no shame in using it
change $(document).click(... to $(document).ready(...
right now you're binding your event handler to the form every time the document is clicked
so if you click the page 5 times, you'll send 5 requests when you click "submit"
no, bind it to the button
almost, but you can change your submit handler back to $('#form_register').on('submit', ... to make sure you catch any way that the form is submitted
no, you need the form
and add the ID to the form, not the submit button
just have 1 $(document).ready(... call and put everything in there, and make sure your different forms have different IDs
im planning on buying a course from udemy
python and django full stack web developer
it teaches how to use javascript,html,css,jquery and python
what do you guys think?
That's good
You can build a lot of sites with that
But jQuery is getting outdated, you're better off learning React
Here's a much better learning route
but then that doesnt teach django
You don't need Django or Python
You can write server side code with JavaScript
1.) You won't have to learn two languages
2.) NodeJs is more powerful and used more in the industry (from my experience)
kay
I forgot this is a Python sever LOL. My bad everyone.
But still, learn Nodejs 
Web developmen channel is not strictly limited to python frameworks
thanks this course has many more reviews than the previous one
Hey guys, I'm learning django and have something that I can't solve, maybe someone could help me 😀
So, I started my studies with the "Python crash course 2nd edition" book, and one of the projects are a little learning log, where you can add topics and entries...
So, if you enter topics/ it shows all the topics, and then you can select one of them and add some entry
I'm improving the code a little bit, I already put a sidebar, and now im struggling in one thing
I want to show the topics in that sidebar, which I already did with this code in my view
def index(request):
"""The home page for Learning Log."""
topics = Topic.objects.filter(owner=request.user).order_by('date_added')
context = {'topics': topics}
return render(request, 'learning_logs/index.html', context)
But there is a problem, if I go to the page topics/1 (for example, topic 1), then the topics doesnt appear anymore in the sidebar, because the view index was not triggered instead the topic view is... I dont want to put this same line of code " topics = Topic.objects.filter(owner=request.user).order_by('date_added') " in all my views.
There's another way of doing this? Thanks!
In my base.html I have this to show the topics
{% for topic in topics %}
<li>
<a href="{% url 'learning_logs:topic' topic.id %}">{{ topic }}</a>
</li>
{% empty %}
<li>No topics have been added yet.</li>
{% endfor %}
Can anyone suggest any use cases where Flask is preferred over Django
I am learning Falsk instead of Django, I have a hunch it's the right oneand better but both have their own uses
Flask is a like Startapp application and gateway from backend to front.. django is a more functionaly, powerful framework..
my advice to you is Learn flask, it is easy and understandable 🙂 in future you can easily move to django 🙂
QUESTION:
i have api based json lists,.. i want save each item to my local DB...
def index(request):
profile_id = 12345
profile_api = 'xS12POxJeUQkLweR6huob'
r = requests.get(f"https://aexample.com/user/{profile_id}?&key={profile_api} ")
rdata = r.json()
return render(request, 'tp_template/tp_profile.html')
if we use print (rdata['name']) in console printed profile name. everythong works fine...
just want this profile name and other data from API store to my local DB ..
Hey
I want to start a new project where I make a chat application using sockets
What python module should I use to make the UI
or should I even use python
for the UI
I'm down to learn Javascript just for this , but is it worth it ? Or can I make a nice UI with Python
@ornate dew If you're making a chat application, then yeah you'd have to use javascript, unless you'd want people to refresh the page to see new messages (bad design). You could still have Flask or Django run the application on the backend.
Ahahah okay
flask's big advantage is that it's kinda small and simple
I'll go with flask then
both of them are excellent, it all depends on what you want to do. flask comes with a lot less and you have to explictly define more stuff. django comes with a bunch more and has a bit more of a learning curve, but has a "batteries included" approach so much of what you need is already included
django's advantage is that has a lot of handy stuff built in , particularly if you're using a SQL database
at the same time though, flask has flask-sqlalchemy which isn't hard to use (I've done multiple projects with both)
cant I just use a cursor
if you know how to use one, it doesn't take much effort to learn the other
for SQL
I never worked on that low of a level for what I've done, but I think you can do that with any orm
they just give you an abstraction layer to treat tables as classes, rows as objects, and columns as attributes/properties, bringing OOP into it
ooh
yes its another thing to learn, but once you get it you can do stuff much faster and simpler
you can even give the models methods, just like a normal object would have
I have a question regarding aggregating ORM data for visualization and 'condensing' events. I'm keeping track of API calls to a django server, and every request becomes its own object internally, recording multiple things about it but most importantly in this context- the time it was received. All of this data will be kept for some period, and then automatically purged after a month. My question comes in two different pieces:
-
How could I visualize this data, through something like matplotlib? The graph would take the total number of API requests in 15 minute periods, and then aggregate that data into a graph. And of course, there would be different views for hourly/daily. Is this something built in or that exists somewhere?
-
Even after the objects are deleted to conserve space, there should be some lower resolution form of the analytics data left over for historical reference. Again, does anything exist that does this?
Making this functionality wouldn't be a problem, but I'm just asking to see if anything like this already exists just so I'm not needlessly spending time reinventing the wheel. The data visualization/analysis aspect of web dev work is completely new to me, any input would be appreciated. If this question is better suited for #data-science-and-ml I move it there instead. Thanks.
is using js better than using python for backend web dev
Hi can anyone help me with an error in my server
414 Request-URI Too Large
i get this when i try to load a page which has large number of data passed to it using get
In aiohttp after starting a web server, is there a way to remove the:
======== Running on http://0.0.0.0:8080 ========
(Press CTRL+C to quit)
or not?
In Flask, is it possible to do something where I have the website path localhost:5000/dashboard. Going to that page will show a list of options that are always changing (never static data on this page) that you can select. Ltes say that there are 3 items. A, B, and C.
A has a value of 1000
B has a value of 217
C has a value of 9887
If I click on A it would go to the link localhost:5000/dashboard/1000
B would go to localhost:5000/dashboard/217
C goes to localhost:5000/dashboard/9887
They all load the same base template, but they all get data from my database. The data will vary between each value (1000, 217, 9887)
@app.route("/dashboard/????")
def pageView():
return render("baseFile.html", data=MyDatabaseLookup(????))
Because the data on the page will always be changing I cant just hardcode it like
@app.route("/dashboard/217")
def pageView():
return render("baseFile.html", data=MyDatabaseLookup(217))
Please ping me if you can help 🙂
Or ping me if this is not possible to let me know
Hey, everybody! I've been trying to develop an application to list all hrefs in a webpage.
For some reason I am able to get all hrefs from the interpreter, but not from running the script. I have no idea and I'm stumped. Tried troubleshooting.
I'm working with the Selenium module in Python. In the interpreter I set up a variable
links = driver.find_elements_by_id("IDNAME")
for elm in links:
print(elm.get_attribute("href"))
^ this prints all of the links in the interpreter, but if I run a script with the same code, nothing is printed and the application ends.
Anyone know what's going on?
Hey @remote anchor can you update your nickname according to our nickname policy seen in #rules it just needs to be mentionable
@cinder juniper name updated
Thanks, although you just needed to set a nickname for the server. Didn't have to change your discord name
@cinder juniper Good to know for next time. Thanks for bringing it to my awareness
What do you mean when "running the script" how are you doing that?
python ./scriptname.py
^contains the same code that I run in the interpreter, but does not print href links. The python ./scriptname.py ends without printing links unlike the interpreter running the same code
If you add a print('Test') to the top, does that print out?
@cinder juniper Correct
Hmm, if that is printing but not the rest then I'm really not sure. If there's no errors then really it should be working
i know, right 😦
I haven't worked with Selenium so idk if it could be because of that
Thank you for trying to help, @cinder juniper
If i wanted to add input validation to my website, would i put the code client side or server side?
hey guys, i was wondering is there way to show some buttons only to certainpeople, like menages with role system?
in flask
could somebody help me with html? (basics)
I need this
to be like this
<ul class="zakupy">
<ol start="5">
<ol type="I">
<li>chleb</li>
<li>mleko</li>
<li>maslo</li>
<li>szynka</li>
<li>ser zolty</li>
<li>dzem</li>
<li>cukier</li>
</ul>
<style>
ol.zakupy {
list-style: upper-roman;
}
</style>
hey guys
the upload of a picture with flask doesn't work
am i doing wrong?
if form.validate_on_submit():
if form.picture.data:
picture_name = secure_filename(form.picture.data.filename)
file_path = os.path.join(app.root_path, 'static/profile_pics', picture_name)
form.picture.data.save(file_path)
current_user.image_file = picture_name
current_user.email = form.email.data
db.session.commit()
return redirect(url_for('account'))
@fickle fox probably you can modify the jinja template if an user is logged in, have some permission or an attribute that you define
@cloud path instead use this
if form.picture.data:
pic = form.picture.data
pic.save(“static/pictures/” + secure_filename(pic.filename))
user.picture = pic.filename
This might work
thanks for your reply, but nothing it still doesn't work :/
something like: {% if current_user.is_authenticated %} your buttons things {% endif %}
id perform the checks also in the views because im paranoid
This works well but have you used enctype in the form tag?
yes i have
and this is my flask form:
class UpdateAccountForm(FlaskForm):
email = StringField('Email', validators=[DataRequired(), Email()])
picture = FileField('Carica l\'immagine di profilo', validators=[FileAllowed(['png','jpg'])])
submit = SubmitField('Aggiorna')
def validate_email(self, email):
if email.data != current_user.email:
user = Account.query.filter_by(email=email.data).first()
if user is not None:
raise ValidationError("Email già utilizzata.")
Use your form.picture.data in a separate variable because once i used it like form.picture.data.filename it gave me and error
Try it like
var = form.picture.data
alright (y) i'm trying, i'll let you know
No to access the form data from the inputs in flaskform the data is tru
alright
btw i tried like that
if form.picture.data:
pic = form.picture.data
picname = secure_filename(pic.filename)
pic.save("static/profile_pics/" + picname)
current_user.image_file = picname
If its an html form we use request.form[“var”]
but still nothing
Ooh okay i will try it
Ok ok
i'll try to do other things thanks anyway
Yw
@fickle fox dunno if that's best practice but it's what i use to show buttons in a navbar to registered users
I'm saving files locally with this and it's working:
saved_filename = f"{str(uuid.uuid4())}_{filename}"
fpath = os.path.join(current_app.config['UPLOADS_DIR'], saved_filename)
upload_file.save(fpath)
and my UPLOADS_DIR is defined like this:
UPLOADS_DIR = os.path.join(APP_DIR, 'static', 'uploads')
APP_DIR = os.path.abspath(os.path.dirname(__file__)) # This directory
oooh, I am trying to make 'forum' with possibility for moderators to move posts to different sections, to edit and delete posts, and things like that, and i dont want other users to have that option as well
@cold anchor thanks for sharing, i'll try like that too
if that doesn't work for you I can share the full view & model code
Probably Flask have an extension for permission or you can use pass a boolean to the view
I think you still need to check if an user can or cannot do something, because you would only show/dont show the button, but they would still be able to do the action by crafting themselves a request
Someone more versed in this than me can probably chip in
I have an app that does this hold on I can get some sample code
# myapp/views.py
...
from myapp.auth import super_admin_required
...
@blueprint.route("/private")
@super_admin_required
def do_private_logic():
# protected logic here
return {'status': 'ok'}
...
# myapp/auth.py
from functools import wraps
from flask import current_app, abort
from flask_login import current_user
super_admin_roles = set([
'sadmin',
'uadmin',
])
def super_admin_required(f):
@wraps(f)
def decorated_function(*args, **kwargs):
if not current_user.is_authenticated:
abort(401)
if current_user.role not in super_admin_roles:
# TODO: 403
abort(401)
return f(*args, **kwargs)
return decorated_function
# app.py
...
@app.errorhandler(401)
def render_401():
# another option could be to redirect to an allowed page
# return redirect(url_for('app.public'))
return render_template('401.html')
then just add a "role" column to your users that contains a string
Following up from my azure deployment issues yesterday. I gave GCP a try to see if it was maybe a platform issue. Total time on the back end to perform the operation was 3-4 seconds, total time for client to send then receive was 16.9 seconds. This is down from 22 seconds on Azure, but up from 3 seconds locally.
network bottleneck maybe?
can you click on that request in the network table and check the "timings" breakdown of it?
Cool- I didn't realize that was a thing!
nice!
so the "waiting" amount of time lines up with what you're seeing on the server, then
and the content download is fast
it might be worth looking up what the "request sent" means in chrome to help nail down where it's hitting the bottleneck
Sounds great, thanks both of yall!
I think the request sent is the time a promise takes to resolve since all requests are promises
I am guessing it might be a network bottleneck then
Try running from another device, maybe using data connection
It also might be that promise thing
What is the request body?
I'm sending an image and receiving back a small json object with text and coordinates of where that text is located on the image.
Since you are sending an image an upload might take time
brb
Here is a resolution I can recommend you, although not sure how much it can reduce the time it takes to upload it: Convert the image to base64 and send it as a plain string, then decode it server side and get the image object
what is the content-length value in the request headers for that request?
sorry about the delay - I had a meeting. I'm going to do a little more reading on headers and then I'll have that info for you
it's in the "headers" tab of that request, near the "timings" tab
21mb transfer over 14 seconds is just under 2mb/s upload speed
so it seems like it's just a slow connection
So does this mean that my browser (client, right?) is sending the entire image back to the server?
As in client -image-> server -image-> google_vision -results-> server -results->client?
If so, then the solution would be to send the coordinates (4 x,y points) to the back end, have it send the image (like it is already doing) to google_vision, then return the results
yea, connection is slow
<h3>Recent Vouches</h3>
{% for vouch in vouches %}
<h2>Author : {{ vouch['author'] }}</h2>
<h2>Member : {{ vouch['member'] }}</h2>
<h3>Vouch Value : {{ vouch['value'] }}</h3>
<p>Comment : {{ vouch['comment'] }}</p>
{% endfor %}
at first when i run flask app it displays everything
but when i refresh page documents disappear completly
i am using mongodb/pymongo
am i doing something wrong?
profiles = collection.find().sort('_id', pymongo.DESCENDING)
vouches = collection2.find().sort('_id', pymongo.DESCENDING)
@app.route("/", methods=['GET'])
@app.route("/home", methods=['GET'])
def home():
return render_template('index.html', profiles=profiles, vouches=vouches)
if __name__ == '__main__':
app.run(debug=True)
@twilit zenith i'm not super familiar with pymongo but I think I know the problem. i'm guessing collection.find().sort() is a generator function, which can only be iterated over once. Therefore, defining it at the top means it's a one-shot and done
put lines 1 and 2 inside def home
guuys i am trying to make registration form
is this good or would you change something?
def registrate():
render_template('register.html')
if request.method == 'POST':
name = request.form['nickname']
email = request.form['mail']
passwords = request.form['pw']
submitpw = request.form['rpw']
ph = PasswordHasher()
hash = ph.hash(passwords)
if ph.verify(hash, submitpw) is True:
new_user = Users(
name=name,
mail=email,
pw=hash)
db.session.add(new_user)
db.session.commit()
else:
print('Try again')
else:
redirect('register')```
can i specify user agent, content type/length etc as data in a post request?
add a honeypot field to the form
an <input> that is hidden with css so a human user should never fill it out
name it something like "email-confirm"
then if you get data in that field you know it's a bad request and you should abort(418)
can i specify user agent, content type/length etc as data in a post request?
@warm spire That can be edited, do what @fresh dock said
ooh i never heard for honeypot
418 is "I'm a teapot" but I like to use it as a "no fuck you" error code
The correct return if you encounter a bot is 403 forbidden though, but I'd just send a 200 OK to throw the bot off
i ll google it thanks 😄
weird now i dont see inputs at other pages
yeah idk why tho i cant see input fields
i have different fields in different html pages, is there a way to select them?
wait exstra css class?
i cant see them in an older page
If you write something like css input[type=text]{ display: none; }that applies to all inputs
.email-confirm{
display: none;
}```
is that done with wtf flask fields?
in css...
ohh will check it now
you'd have
<input id="email-confirm" name="email_confirm">
in the html
then
in css
input#email-confirm {display:none}
@tired root @fickle fox ^
if you do with a class or id makes no difference in this case
@app.route("/registrate", methods=['GET', 'POST'])
def registrate():
if request.method == 'POST':
name = request.form['nickname']
email = request.form['mail']
passwords = request.form['pw']
submitpw = request.form['rpw']
ph = PasswordHasher()
hash = ph.hash(passwords)
if ph.verify(hash, submitpw) is True:
new_user = Users(
name=name,
mail=email,
pw=hash)
db.session.add(new_user)
db.session.commit()
return redirect('/posts')
else:
render_template('/registrate')
else:
redirect('register')
<form class='formm' action='/registrate' method='POST'>
<input id="nickname" type="text">
<br/>
<input id='mail' type='email'>
<br/>
<input id='pw' type="password">
<br/>
<input id='rpw' type='password'>
<br/>
<input id='sbm' type='submit'>
</form>```
i cant load /registrate page
and its doing something with code at other sides
idk what would be wrong
this is error
you're not returning in the last redirect and render_template calls
So it doesn't look like digitalocean allows you to register a domain name. Who should I use? The only other site that I know of is GoDaddy
A service that allows you to edit your DNS entries
and that is located in your country is probably a good consideration as well
Example: if you own a trademark and are located in the EU, a registered domain in the US won't do you any good if your trademark is not worlwide
someone could register the tm in the US and snatch the domain from you
other way around applies too
Probably not an issue for you right now, but can if the project is successful
@native tide
Hi there, is there any way for a Django parent template to always have a variable? My navbar shows a number next to notifications (just like facebook). I could wire it through every view but I feel like there is a better way. Thank you.
@tired root I'm US-based and might site will be also
Someone recommended namecheap so maybe I'll try that
Leaving this example here to show you what not to do.
html
<span class="spanny" style="some-prop:10px;">This is very spanny text</span>
css
span {
some-prop: 10px;
}
span.spanny {
some-prop: 10px;
}
Spent the last 4 hours trying to figure out why
{% if user.username == model_object.owner %}
wouldn't evaluate to true. They both printed the same username.
Turns out I was comparing a string with a user object, but the __str__ made me think it was a string. Just needed to compare 2 objects...
{% if user == model_object.owner %}
Wasted half my day
guys, see if you understand this error:
werkzeug.routing.BuildError: Could not build url for endpoint 'edit_post'. Did you forget to specify values ['id']?
my .py script:
@app.route('/news/edit/<int:id>', methods=['GET', 'POST'])
def edit_post(id):
post = BlogPost.query.get_or_404(id)
form = Post()
if request.method == 'POST':
if form.validate_on_submit():
post.title = form.title.data
post.author = form.author.data
post.content = form.content.data
elif request.method == 'GET':
return render_template('edit_post.html', post=post, form=form)
my .html file:
{% block content %}
<div class="container">
<form method="POST" action="{{ url_for('edit_post') }}">
<h1>Edit Post : {{post.id}}</h1>
{{ form.csrf_token }}
{{ wtf.form_field(form.title) }}
{{ wtf.form_field(form.author) }}
{{ wtf.form_field(form.content) }}
<input type="submit" value="submit">
</form>
</div>
{% endblock %}
I'm really new to Django, but in my forms, I've been directing the action attribute to url routes, not to view functions.
I can't read all your code, but it looks to me like you're directing it to the function. Though you have that @app.route line and I'm not knowledgeable enough to know what that does.
url_for is supposed to take a view function, and return ... the url for it 🙂
the thing gets created like this:
{% if message.tags == 'error'%}
<script>M.toast({html: "{{message}}", classes: 'blue-grey darken-2', displayLength: 3000});</script>
{% endif %}
i have a couple of /api routes. i want my /api route only accessible by post requests but i dont wanna go change every decorator to methods=["POST"]. is there a cleaner way to do it?
i use flask
settings-bundle.js:1
Failed to load resource: net::ERR_FILE_NOT_FOUND urlbar-bundle.js:1
Failed to load resource: net::ERR_FILE_NOT_FOUND components-bundle.js:1
Failed to load resource: net::ERR_FILE_NOT_FOUND background-common-bundle.js:1 Uncaught TypeError: Cannot read property 'getUILanguage' of undefined
at Object.<anonymous> (background-common-bundle.js:1)
at r (bundle.js:1)
at Object.<anonymous> (background-common-bundle.js:1)
at r (bundle.js:1)
at Object.<anonymous> (bundle.js:1)
at r (bundle.js:1)
at Object.<anonymous> (bundle.js:1)
at r (bundle.js:1)
at Module.<anonymous> (bundle.js:1)
at Module.<anonymous> (bundle.js:1)
browser.html:1 Not allowed to load local resource: chrome://vivaldi-data/css-mods/css
DevTools failed to load SourceMap: Could not load content for chrome-extension://odbfpeeihdkbihmopkbjmoonfanlbfcl/sourcemaps/contentscript.js.map: HTTP error: status code 404, net::ERR_UNKNOWN_URL_SCHEME
when opening an HTML resource of vivaldi
Vivaldi is an electron app
Anyone know is the twitter API allows an app to tweet on the behalf of a user?
I am using the python-twitter library
Hey guys for Django, idk why but I can’t seem to get updates on MySQL workbench when my website is on production
Do we have to make migrations after we deploy the app even though we can done it locally(but to a remote database, a the configurations are the same during deployment)
Have done it locally ****
hey guys, self explanatory issue in my image:
i'm using bs
i tried 'pull-right'
but no result
Hello
so i'm done with the backend for my messaging app
but for the front end
I dont know what to do
I cant use css
I dont understand it
is there a way to get a quick UI
easily?
@ornate dew perhaps bootstrap? https://getbootstrap.com/
its about as easy as it gets
plenty of themes available for it as well https://bootswatch.com/
There are themes I can just snatch right away?
yes
go on bootswatch, and you'll see links for the css. you can either get it from a CDN, or download it locally
do I need to dl bootstrap?
you don't have to download it locally, just depending on what you're doing its sometimes the better option. like I have a web app running on a raspberry pi in my room and the css is local; if the internet ever went down the application would have no css. that kind of thing
in most use cases you can just use the link. I think twitter runs/funds the CDN
My web app will run on my Cloud Server
then yeah, just linking to it would be the best choice
you dont have to include the css from the bootstrap website btw. if you're using a theme, it contains all of the css. just saying lol
np lol, we all started there
don't know offhand exactly, let me check fast
okok
<link href="http://somewebsite.com/style.css" rel="stylesheet">
I think the bootswatch website actually has the code too...
Ok
no I was wrong, but here is the site with the link you'll want: https://www.bootstrapcdn.com/bootswatch/
so just choose the one you want on bootswatch, plug the link in to the <head> and bingo bango
if you're new to bootstrap I'd go over the components and how layouts work (not hard) https://getbootstrap.com/docs/4.3/components/alerts/
anyway I threw enough at you I think lol
One last thing
I have these html elements
<ul id="messages"></ul>
<input type="text" id="myMessage">
<button id="sendbutton">Send</button>
How do I change their position
in the page
thats where the bootstrap components come in
Ok
theres a lot of templates to use so you dont have to reinvent the wheel generally
some hate it some love it... but its a pretty opinionated framework
if you just want it to work and dont mind a simple interface, yeah its perfect
I'll never stop using it
If I want to use css
in an html
file
how do I do it
rn
it just pops
oh i got it
its style
if you want to use the css elements, its pretty much all classes
hello is anyone here into web scraping using beautiful soup and requests?
@gusty sage Won't say I'm 'into it' but I've used it for work.
here is the part of the html?
@gusty sage y did quiet a bit of scraping
Do any one know email verification in flask
Like confirming that the user owns the email they signed up with?
@cold anchor yes
do you already have a way to send emails from your server?
Hmm I'm using sendgrid because port 25 is blocked in gcp
I don't know if the cat is right
I am asking here.
I am making a discord bot using Flask
make a token for a user in your db then send it to the user's email and ask them to click a button to verify which is a link that takes them to your server with the token you made for them
Oh then can I also create a var in db as ‘is_verified=True/False‘
Hello
Hey guys.. there is a limit of using JS with django? or django is open to work with all javascript methods?
I am getting this error
Running on http://127.0.0.1:5000 (CTRL + C to quit)
[2020-05-13 20:05:46,471] Running on 127.0.0.1:5000 over http (CTRL + C to quit)
[2020-05-13 20:05:49,235] ERROR in app: Exception on request GET /
Traceback (most recent call last):
File "F:\Python Discord\lib\site-packages\quart\app.py", line 1807, in handle_request
return await self.full_dispatch_request(request_context)
File "F:\Python Discord\lib\site-packages\quart\app.py", line 1829, in full_dispatch_request
result = await self.handle_user_exception(error)
File "F:\Python Discord\lib\site-packages\quart\app.py", line 1074, in handle_user_exception
raise error
File "F:\Python Discord\lib\site-packages\quart\app.py", line 1827, in full_dispatch_request
result = await self.dispatch_request(request_context)
File "F:\Python Discord\lib\site-packages\quart\app.py", line 1875, in dispatch_request
return await handler(**request_.view_args)
File "F:\Python Discord\lib\site-packages\quart\utils.py", line 70, in _wrapper
result = await loop.run_in_executor(
File "F:\Python 3.8.2 (x64)\lib\concurrent\futures\thread.py", line 57, in run
result = self.fn(*self.args, **self.kwargs)
File "F:/PyCharm Python Works/OpenCityBot/Bot/bot.py", line 71, in hello
return "Hello from {}".format(bot.user.name)
AttributeError: 'NoneType' object has no attribute 'name'
Executing <Task pending name='Task-15' coro=<ASGIHTTPConnection.handle_request() running at F:\Python Discord\lib\site-packages\quart\asgi.py:78> wait_for=<Future pending cb=[<TaskWakeupMethWrapper object at 0x000002186495A160>()] created at F:\Python 3.8.2 (x64)\lib\asyncio\base_events.py:422> cb=[_wait.<locals>._on_completion() at F:\Python 3.8.2 (x64)\lib\asyncio\tasks.py:507] created at F:\Python Discord\lib\site-packages\quart\asgi.py:26> took 0.156 seconds
[2020-05-13 20:05:49,393] 127.0.0.1:62021 GET / 1.1 500 29031 167003
my_presence_per_day.start()
add_guild_to_json.start()
app.run(host="127.0.0.1", port=5000, debug=True, use_reloader=False, loop=bot.loop)
bot.run(TOKEN)
Please help
That's happening because your bot.user is None
And None object doesn't have .name attribute
Make an if statement that tests whether bot.user is None or not
are you trying to mix flask and Python?
def registrate():
render_template('register.html')
if request.method == 'POST':
name = request.form['nm']
email = request.form['mail']
passwords = request.form['pw']
submitpw = request.form['rpw']
ph = PasswordHasher()
hash = ph.hash(passwords)
if ph.verify(hash, submitpw) is True:
new_user = Users(
name=name,
mail=email,
pw=hash)
db.session.add(new_user)
db.session.commit()
return "registrovani"
elif ph.verify(hash, submitpw) is False:
return render_template('register.html')
else:
return 'Site crashed, reload it and try again'
else:
return render_template('register.html')```
guys i am trying to reddirect user if hashed pw and submited one doesnt match, but its conttstantly giving me error
how can i fix it
maybe to do with js pop up msg or something
but firstly to fix this
what's the error?
argon2.exceptions.VerifyMismatchError: The password does not match the supplied hash
I'm confused why you're going through the trouble of hashing both of them if you just want to verify that they match
why not if passwords != submitpw:
ooh okay
Does anyone know if it's possible to route and render Pelican through a Flask development server or am I just going about this wrong?
and just use the pelican development server
@ionic plover What is Pelican?
It's a static website generator.
Doesn't make much sense then
Why deliver static html through a dynamic system,?
Just set up nginx or apache and you are good
Or asked differently: What do you expect flask to do with the html?
Yeah like I got Pelican set up with a theme and all to create a blog website but I thought I could get it running through a flask developement server to serve the website to display on the web browser.
If you need a plain html quick server, python -m http.server on the directory you want to serve
or just grab Nginx container, throw your JS/HTML into there and set it loose
Is this the best place to talk about hosting services?
cuz i want to know if Netlify is actually that good
What are the pros and cons of Netlify?
@zealous siren Totally overblown
For a bunch of html files on a local pc the built-in python http server is more than enough
ok
Asking good questions will yield a much higher chance of a quick response:
• Don't ask to ask your question, just go ahead and tell us your problem.
• Don't ask if anyone is knowledgeable in some area, filtering serves no purpose.
• Try to solve the problem on your own first, we're not going to write code for you.
• Show us the code you've tried and any errors or unexpected results it's giving.
• Be patient while we're helping you.
You can find a much more detailed explanation on our website.
Hi, I am studying Information Technology in Brazil, but in my country there is not much content about programming language. I was wondering if you can send me pdfs of books that have great content on programming languages, especially if it is focused on html / css and C #announcements
The Resources page on our website contains a list of hand-selected learning resources that we regularly recommend to both beginners and experts.
here are some tutorials and stuff
So give me a good book
entitled much?
indicate some tutorials on youtube as well if you can, whatever you can to help. Thank you
I gave you a link with lots of tutorials, but we are not giving you books
We're a large, friendly community focused around the Python programming language. Our community is open to those who wish to learn the language, as well as those looking to help others.
do you have links that teach html / css or c #?
I can't figure out what am I supposed to do. I am using DRF and I want to access some endpoint but show different result if a user created that resource and another result if some other user is accessing it. I'm using Session Authentication.
I can't figure out what am I supposed to do. I am using DRF and I want to access some endpoint but show different result if a user created that resource and another result if some other user is accessing it. I'm using Session Authentication.
Do you have google?
I mean, seriously, it is ok to ask for help, but you need to show some initiative as well
I gave you our collection of resources, read it, pick something and learn
This is a python discord, if you want to learn C#, this isn't the place
Yes, but you who program longer may know of a better option so that I don't waste time on unnecessary sites
If you don't want to help, I'll wait until someone with empathy helps me. Thank you
I cant comment about C#, but with HTML and CSS... It's been a very long time since I learned the basics of HTML, so its kind of difficult for me to think of a good modern resource. The main thing I can say is to make sure you're learning from an updated source.
https://developer.mozilla.org/en-US/docs/Learn/HTML
I would recommend mozilla docs for just about anything frontend webdev related. They will really be the authority on most things.
If you're looking for something that is less, "dive into the documentation", this site is pretty good for most frontend things as well, though Id avoid it for JS lessons tbh.
mainly because it will set you on a path to writing outdated JS.
Is it possible to run flask server and python codes from phone?
i searched on google and finded that http://neilkarwasra.blogspot.com/2017/08/how-to-install-and-run-python-flask-web_15.html
how is this not matching the one below?
I was using this website to learn django ... https://simpleisbetterthancomplex.com/series/beginners-guide/1.11/ .... but soon i realised it is outdated since django is on version 3 now... can you guys recommend a good updated resource please?
Okay wait @inner ridge
You can go for it
Or if you want to study with video lectures then you can find so many courses on udemy, where i learned it
@amber storm guess I could help you with that
But can't really right now...... Tomorrow maybe
it is the question mark messing with it, thanks for the offer tho!
👍 recently built a complete web application with Django
So played quite a lot with it
I dont get something in sqlalchemy Table object
In the following.c.followers,
What is c?
Is this doing my due dilligence assuming there is no profit on the site, and I have searched this much to try to identify the person but can only trace it to pinterest sharing. I imagine for someone who truly cared, they could dig deeper. My question, is it my due dilligence to care about finding the person who released their art and then made it such that when I search for the image, they are not the first thing that comes up. Because imo, if they chose not to do that, then there would be no way for them to not be credited. There would be no way for me to ignore a "do not use request" -- but when something is shared all over the internet to the extent that some things are, is it wrong of me to just clip some image and use it in in a web design, when I cant find the original artist because they have no site publishing it?
hello, does anyone know how I can run my flask app publicly?
rn its running on localhost
I have this that shows up
when I try to use Apache to run it on my cloud server
my stuff is in /var/www
hello, does anyone know how I can run my flask app publicly?
@ornate dew yea
😮
when I try to use Apache to run it on my cloud server
@ornate dew use nginx is easier than apache to run flask
nginx, how do I set it up
@ornate dew you are using which cloud
wdym which cloud
?
My Cloud Provider?
Yea
Digital Ocean
Oh ok
sudo apt install nginx
it's Debian 9
@ornate dew debian and ubuntu are mostly the same
@ornate dew for apache
@ornate dew oh ok
Is it apache
Ya
Oh ok
ill try with nginx
I also run my flask in nginx
Ok
is the virtual environment part necessary?
Hmm it's up to you
And forgot to tell you run your flask development server on port 5000
isnt that the dev port
@ornate dew Mmm for me I did all the steps it didn't work after changing the dev port in the mainfile.py it worked but in nginx I kept port 443
@ornate dew did it work?
Have phpstorm autocomplete in html ?
Is it possible to upload (through ftp-transfer) a .db database and use it together with a flask/django website? Ie. make a working website offline and upload everything - will it still work?
Need help with WebSocket here
https://github.com/tiangolo/fastapi/issues/1411
[do any one know how to make loop in flask (HTML) file
Haven't tried it myself, but have you checked out this guide?
@native tide thanks:)
Please report back if it solved the issue. I am still early in the course, so have not had the chance to test myself yet 🙂
Anyone can explain to me the the primaryjoin and secondaryjoin in SQLAlchemy?(i dont get it properly)
Hello everyone ☺
I have a job in a company as a Python developer but I want to find another jobs for the week-end to make more money.
Do you Know where can I find short jobs while working at home ?
upwork might be a good place to start building a freelance portfolio
if you want to go further than that I'd recommend registering as a company and building a website and advertising/reaching out to local businesses
@cold anchor did you try upwork ?
I haven't personally, their rates for somebody just starting is way lower than I would charge- I use my network to find freelance opportunities
surprisingly, I've also had people reach out about freelance from reading my blog posts, so that's another avenue you could use
I tryed freelancer, i cant find a job
I need to show some projects that i am not total beginner :(
So i will try to make website for free
And use it as reference
You pay someone to read your blog posts @cold anchor ?
start with personal projects, things you want to build, you don't need to just do free work
no, I don't pay anybody to read my posts, they're all available on medium
I am now making something like forum, tho whenever i made small change at code i mess up something else :(
writing tests might help with that!
Did you earn money with freelancer @pulsar ivy ?
Nope
Never
I never got actual job in there
So i am just in contact with experienced people in this field, they are navigating me
I cant wait to get first income 
@gleaming herald that’s more #414737889352744971 question. Likely with 10k WSS, you will need to spin out more instances and include a load balancer
So I’d get your FastAPI going in container
That I am doing now too @zealous siren
But the thing is if I restart the RESTAPI Code
The websocket file can accept more connections
And 1000 websocket per instance is a little too less?
Not necessarily
Are websocket and Rest API mixed in same server?
If so, I’d separate them if possible
☝️
they do 2 very different jobs and you'll likely see better performance from both if you separate
But to scale, likely you will need multiple containers and load balancer possibly with right hand side request routing
But to scale, likely you will need multiple containers and load balancer possibly with right hand side request routing
@zealous siren https://blog.jayway.com/2015/04/13/600k-concurrent-websocket-connections-on-aws-using-node-js/
I recently faced the challenge to get as much power as possible out of a AWS EC2 instance at the lowest possible cost using concurrent persistent websockets. To do this I needed to use a event-driven, non-blocking runtime environment. For this particular purpose Node.js is exc...
Here is one example without containers
but they use node.js
My configuration is 8 cores
Ops is very trial and error using hard numbers
with 16GB Ram
another cap is the number of max open files on the server, max connections can't exceed that
run the ulimit command to see what this number is
👍
Gunicorn isn’t multiple processes just multiple threads
@zealous siren I'm using uvicorn
The workers which is configurable uses processes
also gunicorn does use processes instead of threads https://docs.gunicorn.org/en/latest/run.html#commonly-used-arguments
AFAIK
Cool
The lightning-fast ASGI server.
But I assume there is built in LB handling
another cap is the number of max open files on the server, max connections can't exceed that
@cold anchor How does WS is connected to max open files
Gunicorn uses uvicorn
@cold anchor How does WS is connected to max open files
@gleaming herald I remeber getting error of too many files open once or twice
for each connection your server needs to open another file, if you hit the max number of open files, you can't accept another connection
Aah
Again if your server is dying under load, at work, step 2 is toss a load balancer at it and spin up multiple instances
Even if it’s on same server
Another problem would be
If one container has accepted a ws connection
next time it should go to the same container
Why?
Because your open connection would be inside that container
If you go to different container it would not have your connection and probably start a new connection to wsserver
Load balancer would keep open socket with same container
Which is what I am
I was just curious and wary about
why the concurrent connection number is soo low
Is it normal
or I was doing something wrong?
I guess my question for you is: what are you optimizing for? (practically) are you hitting errors when your thousands of users connect? are you trying to future-proof your scale and keep your costs low?
I guess my question for you is: what are you optimizing for? (practically) are you hitting errors when your thousands of users connect? are you trying to future-proof your scale and keep your costs low?
@cold anchor the latter
For a lot of languages, it’s garbage collector
I can do a hard limit by seeing that if number parallel connections are more than 1000 directly tell them
but that's more like scapegoat
I wanna scale well
tbh, I'm of the mindset that you should deploy your app and let this problem happen, then solve it
We run into same problem with C#
this is what I would call a "good problem" to have- you have so many users that you're hitting errors in something underlying your app code
We run into same problem with C#
@zealous siren Can you expalin more
this is what I would call a "good problem" to have- you have so many users that you're hitting errors in something underlying your app code
@cold anchor That's what I was wondering
When you try and scale inside same “process”, the garbage collector is What causes the load issues
TBH it's a whatsapp bot and since callbacks of WhatsApp are in RESTAPI I'm building it
Thus separate processes and load balancer
And since the client would be Amazon or Uber Bot
You can easily expect atleast 10K parallel connections
Thus separate processes and load balancer
@zealous siren Aaah
but can you expect 10k connections right now? do you have amazon or uber as a customer today?
but can you expect 10k connections right now? do you have amazon or uber as a customer today?
@cold anchor Yes
great- then this is a problem worth solving lol, just wanted to confirm that
What cloud you using?
What cloud you using?
@zealous siren Currently we have our own servers
great- then this is a problem worth solving lol, just wanted to confirm that
@cold anchor Exactly
Ehhhh
you have racks of servers you're keeping on prem?
Thus separate processes and load balancer
@zealous siren So keeping API And WSSERVER seperate would help?
you have racks of servers you're keeping on prem?
@cold anchor Yes
wow
so at my last job we decided to break out the WS server from the http servers and use a totally different language
none of us were experts in a framework that did a great WS job so we learned elixir quickly and made a separate websocket service
we had similar issues and contracted the author of the phoenix framework to help us scale our connections
and it worked like crazy, our memory and cpu load went way down and we had clear signals for "you need to spin up a new server and put it behind the LB now"
because the limit was the # of open files on the server
The problem would be I'm using a AI model in WSServer and i'm pretty sure migrating a complete service would be a bad idea
And ML/AI is done much easily on python then on another server
because the limit was the # of open files on the server
@cold anchor I'm pretty sure it's the same issue
would need to see how to increase this limit
have your AL/ML service be an http API that sends messages to the WS server
make them two distinctly separate services
by the time I left that job we had just passed 1MM concurrent connections
phoenix/elixir
and use rabbit's advice too: have a load balancer
Aah! Okay
have your AL/ML service be an http API that sends messages to the WS server
@cold anchor I wish I could
what's the constraint stopping you?
So the AI Model is for Chatbot
we had an NLP service that was done in python and communicated to the WS service to send messages
So the thing is the NLP Service is context dependent
So once you said hello
it starts your intent document
and would fill all the slots
like if you say Hello, book a cab
it would start the service and ask for locations
so websocket is easy in this case
as I can just do recv() on start and when required location I can do it again
if that makes sense
yeah that makes sense
but there's no reason you still can't separate the services
even if they're context dependent
Hey, are there any Django wizards around?
yeah that makes sense
@cold anchor
even if they're context dependent
@cold anchor so how do I create a rest api where everytime I get the request I would know what are the past responses and this should be the reply
so the way we did this was that the server was stateless and every time it got a message from a user it would update and persist the context of the conversation to the database
so the way we did this was that the server was stateless and every time it got a message from a user it would update and persist the context of the conversation to the database
@cold anchor Aah
Any resources you sugges
I 'm not aware of this methodology
sorry, all this stuff was home-brewed so it's not something I can share more details about under my NDA
though I can suggest that you take the "context" you have in your NLP server and imagine it was a blob of data: how would that data look? what questions do you need to ask it?
you can store blobs of data just fine, so that was the general method we used
just a dict filled with the context of the conversation
Yeah
just a dict filled with the context of the conversation
@cold anchor
hi_flag = False
message = await websocket.receive_bytes()
if message == "Hey":
hi_flag = True
reply = f'hey, there {user_id}'
await websocket.send_bytes(reply)
message = await websocket.receive_bytes()
if message == "hey":
reply = f'Hey you already said Hi ! WTH !'
await websocket.send_bytes(reply)
if message == "Goodbye":
if not hi_flag:
reply = 'Hey You did not say HI !'
await websocket.send_bytes(reply)
So for a code like this
I would just replace the websocket receive bytes
and I would parse through the blob of data
everytime I get a request?
I'm building a survey site, where a user is being shown a set of images, which are pulled from a database. The user then classifies those images to one of two categories. After this, the user is taken to a new view, where they are being shown those same images and they have to draw on top of them. Now, I have to save these drawings and associate them with the survey participant. Question is, does it make sense to create a Form for the drawings or how would I pull that data from the user's interactions?
conversations_by_user_id = { ... } # this is the mock database
message = await websocket.receive_bytes()
conv = conversations_by_user_id[user_id] # this is the db lookup
hi_flag = conv['hi_flag']
conv['messages'].append(message)
if message == "Hey":
,,,
so part of your logic would include getting and updating the conversation state
Aah
Kinda makes sense
I would suggest imagining a conversation without AI
how would you model, save and fetch the conversation and messages of just a user<>user conversation?
since an AI is just another client of the conversation
Wrjh what country you in?
Being on premise is a killer
But if you need Load Balancer, I’ve used Kemp with good results
And they have virtual appliances
You could roll your own with Nginx likely
But if you need Load Balancer, I’ve used Kemp with good results
@zealous siren Would take a look
Wrjh what country you in?
@zealous siren We have servers mostly in US
But also backup in Italy and India
how would you model, save and fetch the conversation and messages of just a user<>user conversation?
@cold anchor So AI is not used for replying the message it is used to find the meaning and ask appropriate questions so we can get data
Like imagine you come and say Hello, I am rdbaker
The ai would recognize that rdbaker is name and wouldn't ask for name that is name slot would be filled
So the script would go on to next slot that is what is your age
right, and what data does that AI need to make that decision?
that's the question to answer in order to find out how to store the context of your conversation
right, and what data does that AI need to make that decision?
@cold anchor It just needs the utterance
but it also needs to know about past utterances too, otherwise how would it know the user already said hi? (for example)
I can’t imagine doing this completely on premise
LOL
You would rely on AWS?
I guess i'll probably shift to that from prem servers
but it also needs to know about past utterances too, otherwise how would it know the user already said hi? (for example)
@cold anchor Aah that's part of the NLP Layer which I have applied for patent
Like AWS/Azure have really capable load balancer you could just deploy
This conversation would be like 30 seconds long
Like AWS/Azure have really capable load balancer you could just deploy
@zealous sirenAWS is so big
And?
Understanding it would take soo long
I feel
There are million things available
Do one thing in wrong way they will charge IDK What
Anyways Amazon is not known for it's UI/UX Experince
Sure, downside to on premise is amount of time wasted dealing with this
I have a resource that helped me understand using AWS pretty securely in terms of network security if that would help
haven't used azure though
I have a resource that helped me understand using AWS pretty securely in terms of network security if that would help
@cold anchor Yes Please
Sure, downside to on premise is amount of time wasted dealing with this
@zealous siren do you mean something like this https://aws.amazon.com/ec2/autoscaling
💯
https://start.jcolemorrison.com/aws-vpc-core-concepts-analogy-guide/
@cold anchor Looks perfect
Thanks a ton
@cold anchor @zealous siren
https://hashrocket.com/blog/posts/websocket-shootout
Here is useful link to see which language is superawesome for WS
very cool
interesting that they had such memory usage with elixir
after hiring the author to contract with us, we got rid of those problems
We do websockets in c#
But still after a while, you want to load balancer and setup additional servers just for stability and deployment reasons
We like azure since most of PaaS services have private network stuff
@cold anchor Looks like there is a limit on open files and keeping them on same server would have affected it more
We like azure since most of PaaS services have private network stuff
@zealous siren Still AWS is still a mammoth in PaaS
you can bump that, I think we had 50k or so per server
Like it dominates the market a lot
you can bump that, I think we had 50k or so per server
@cold anchor Damn! Thanks a lot
Hi everyone i'm, trying to create a simple webpage that shows the cookies that are stored in firefox. Until now I have not been able to show anything cause the console shows a few errors. Does anyone could help me? What am i missing or i did wrong? I'm leaving the code in a pastebin link. Thanks in advance to everyone who's gonna help me. https://pastebin.com/ac0dPbzY
Firefox will not show website all the cookies
wrjh, Sure, AWS is largest in market share and if it works for you, great, we are Azure because we are C# shop and it made sense for us to go with Microsoft cloud
but we run some python and go
despite Microsoft branding, they try really hard to be language agonistic and mostly succeed
and there is GCP but man is it limiting
Is there any good tut for making login system, I already made registration system
despite Microsoft branding, they try really hard to be language agonistic and mostly succeed
@zealous siren Aah! okay
looks like azure has improved a lot over time
would definitely check it out
9SGx11, figure out which oAuth provider you want to use and integrate wiht it
Google/Facebook are common ones for consumers
Discord is option if you are doing discord oriented setup
If I have two submit buttons in a form and I want both of them to return form data back to a flask display function but after some processing, send to different render templates, is there a variable I can embed in the submit form input to differentiate the buttons?
okay
@fickle fox You could also try the flask mega tutorial
where can i find it?
He makes a functioning blog with a login section, comments, database
ooh thanks
np 😉
i am rn trying to figure out how to open post in different page
Are you using flask?
@kindred marsh Any reason for spamming an invite link?
yes
Yes, that's what spamming is
I am trying to think how to understand where user clicked and where to capture 'POST' METHOD
mostly rn trying to open post
later on i ll creat db for comments
@patent cobalt Do you teach python here or just answer questions of people who are learing python
something like "like" button...
@fickle fox Understood. You can do an if request.method == "POST":
Here is a form I am working on... similar concept...
@app.route("/order", methods=["GET", "POST"])
def order():
if request.method == "POST":
drinkType = request.form["drinkType"]
milkType = request.form["milkType"]
drinkSize = request.form["drinkSize"]
sugarAmt = request.form["sugarAmt"]
extras = request.form["extras"]
myDrink = MyCoffee(drinkType, milkType, extras, sugarAmt, drinkSize)
myTuple = myDrink.returnData()
return(f"{myTuple}")
else:
return render_template("order.html")
@kindred marsh see #community-meta
wait are u trying to display it later or store it in db?
hey guys, is there a way to specify the maximum file size or the maximum image size through FileAllowed from flask-wtf?
@fickle fox - I can replace the return(f"{myTuple}") with a return render_template
I only have that there for testing
Here is an example from when I was learning it...
def entry():
global bookDetails #global instantiation required. Otherwise there is an error about using the variable before declaring it.
if request.method == "POST":
bookName = request.form["book"]
authorName = request.form["author"]
rating = request.form["rating"]
#create a tuple
bookTuple = (bookName, authorName, rating)
#create a dict
myDict = {"book": bookName, "author": authorName, "rating": rating}
x = bookDoc.insert_one(myDict)
#create a list of tuples
bookDetails.append(bookTuple)
#print(bookDetails) <-- Used in debugging
#return render_template("table.html", book=bookName, author=authorName, rating=rating) <-- Used in debugging
return render_template("table.html", bookTuple = bookDetails)
else:
bookDetails = [] #clear any existing tuples
return render_template("entry.html")```
I was using mongoDB in that app
😛
{% block head %}
<title>{{post_opens.title}}</title>
{% end block %}
{% block body %}
<p name ='title' id='title'>{{post.title}}</p>
<br/>
<p name = 'content' id='content'>{{post.content}}</p>
<br/>
<p name = 'author' id='author'>{{post.author}}</p>
{% endblock %```HTML
post_opens = BlogPost.query.get_or_404(id)
if request.method == 'POST':
post_opens.title = request.form['title']
post_opens.content = request.form['content']
post_opens.author = request.form['author']
return render_template('post.html')
else:
return render_template('post.html', posts=post_opens)```
here what would i need to make it functional? or to display text? @knotty seal
You need to pass the data into the HTML template you're rendering... eg:
def post_open(id, author):
post_opens = BlogPost.query.get_or_404(id)
if request.method == 'POST':
post_opens.title = request.form['title']
post_opens.content = request.form['content']
post_opens.author = request.form['author']
return render_template('post.html', title=post_opens.title, content=post_opens.content, author=post_opens.author)
else:
return render_template('post.html', posts=post_opens)
Then...
{% extends 'base.html' %}
{% block head %}
<title>{{post_opens.title}}</title>
{% end block %}
{% block body %}
<p name ='title' id='title'>{{ title }}</p>
<br/>
<p name = 'content' id='content'>{{ content }}</p>
<br/>
<p name = 'author' id='author'>{{ author }}</p>
{% endblock %}
ooh
let me try it
{% for post in posts %}
<h2>{{ post.title }}</h2>
{% if post.author %}
<h3>By: {{ post.author }}</h3>
{% else %}
<h3>By: N/A</h3>
{% endif %}
<p>{{ post.content }}</p>
<a href='/posts/delete/{{post.id}}'>Delete</a>
<a href='/posts/edit/{{post.id}}'>Edit</a>
<p id='time'>{{ post.date_posted }}</p>
<a id='open' href='/posts/post/{{post.id}}>'>Open post</a>
<hr>
{% endfor%}```
this is from what i need to access it
@knotty seal tho i dont see any difference between code in my edit button and that one up there
What is the >
Sorry @fickle fox -- The URL has a greater than sign
<a id='open' href='/posts/post/{{post.id}}>'>Open post</a> <<--
See the extra > after {{ post.id }}
I am also working on my coffee ordering app, so I apologise if I don't answer sooner
its okay
Had to share 'cuz I'm proud of my development 🙂
yeah it looks nice
jinja2.exceptions.TemplateSyntaxError: Encountered unknown tag 'end'. Jinja was looking for the following tags: 'endblock'. The innermost block that needs to be closed is 'block'.
You're missing an {% endblock %}
learning programming is hard 😦
lol Tell me about it
NO QUITING
{% block head %}
<title>{{post_opens.title}}</title>
{% end block %}
{% block body %}
<p name ='title' id='title'>{{ title }}</p>
<br/>
<p name = 'content' id='content'>{{ content }}</p>
<br/>
<p name = 'author' id='author'>{{ author }}</p>
{% endblock %}```
as i see i have endblock :v
soon
i see my victory

Okay @fickle fox - What is that html file called?
i cant get my bootstrap columns to align vertically. what am i doing wrong?
I'm trying to make a flask web app with Flask Login with two types of users: student and manager. I'm not experienced with Flask Login (currently using session). I'm trying to use a mongodb atlas backend with flask.ext.mongoengine to store student and manager data. I'm currently using sqlalchemy. Each student starts out with a manager_id of NULL, but can change to a managers manager_id. I'm not sure how to replicate this behavior with a nosql db such a mongodb using FlaskLogin since it seems like there can't be multiple types of users. Any help would be helpful 😛
@languid shard Each user should have ONE role
And that role defines access
so student is 0, manager is 1
as value
having 2 values for each violates NF1
How should I relate/reference a student to a manager?
1 to many i think
can one manager have many students or many managers have many students?
one manager to many students
Isn't that sql though? I'm trying to shift to a nosql db
Why?
@knotty seal i would neevr notice it thanks xD
now i have just to manage to display text
There's a json file for each user that I want to store along with the sql table. Right now the sql table has the filepath as a column, but I don't think that's sustainable for deployment since heroku deletes files.
Why would you do that?
Here is a discussion for 1:m on SO: https://stackoverflow.com/questions/25485882/mongodb-one-to-many-relationship
Translate them to tables
Or use nosql JSON store
Yeah I'm trying to transition to nosql. @tired root Hmmm that would get messy pretty quick i think. I'll try to pull up a sample json file
@languid shard Use whatever you want, I've linked you the SO discussion above
maybe it helps
{"personal_info": {"name": "", "county": "", "district": "", "division": "", "category": "", "club": "test"}, "leadership": [{"year": "2020", "activity": "Test", "role": "E", "level": "Cl", "duties": " Responsibilities / Duties / Accomplishments\r\n "}, {"year": "2020", "activity": "Vice President", "role": "E", "level": "Co", "duties": "Assist the President.\r\n "}, {"year": "2020", "activity": "Group Leadership", "role": "A", "level": "Cl", "duties": " Responsibilities / Duties / Accomplishments\r\n "}], "service": [], "awards": [], "career": [], "invitations": {}}```
Yeah it looks helpful
that is easy to translate into a database
Yea
Looking at this file just screams relational to me 😄
And even then, there is plenty of systems that will let you throw JSON at it and then select off of it
leadership e.g is a list of dictionaries though
What db you are using, which type and to an extend what product, should always be governed by use case, not because some manager uses the nosql buzz word
Or serverless shudder
I've been using sqlite and flasksqlalchemy through cs50 ide, but thought it was wise to switch to mongodb since it stores data as json naturally
This is just a student project that I want to deploy on heroku
But scorcher is right, you can use relational database
I learned sql like a month ago :). How do you store dictionaries? Would I need to make a table for leadership, service, etc... ?
Yes to second
Hmm git reset --hard 🤣
hey
@app.route('/posts/post/<int:id>', methods=['GET', 'POST'])
def post_open(id):
post_opens = BlogPost.query.get_or_404(id)
if request.method == 'POST':
post_opens.title = request.form['title']
post_opens.content = request.form['content']
post_opens.author = request.form['author']
return render_template(
'post.html',
post=post_opens.title,
content=post_opens.content,
author=post_opens.author)
else:
return render_template('post.html',)```
{% block head %}
<title>{{ title }}</title>
{% endblock %}
{% block body %}
<div class="cent">
<p name ='title' id='title'>{{ title }}</p>
<br/>
<p name = 'content' id='content'>{{ content }}</p>
<br/>
<p name = 'author' id='author'>{{ author }}</p>
</div>
{% endblock %}```