#web-development
2 messages Β· Page 13 of 1
i mean, i'm sure it works, but i'm wondering if spyder's focus on scientific development has downsides for web development
Isn't spyder geared for scientific use
Yeah
I've never used it personally
I'd suggest something like VS Code or Atom as a light weight editor
that's probably a better idea
Here's a tutorial from MS for VS Code if it helps https://code.visualstudio.com/docs/python/tutorial-flask
thanks!
def admin(request):
return render(request, "./templates/adminpage.html")
urlpatterns = [
path(r'admin/', views.admin),
path(r'about/', views.about),
path(r'home/', views.home)
]
this does not work it says no template found
but there is
nvm i fixed it
Do Selenium questions go here?
I find Atom pretty heavy
Notepad++ is very lightweight and will do alright with the NppExec plugin to add a terminal
calling atom or vscode lightweight is a bit of a far stretch π€
anyways, @winter pagoda, yes
its all relative
idk what its like to have a potato pc
even my 2011 baseline macbook managed to run pycharm
@meager anchor thanks, I got some help in #help-croissant which pointed out that element.screenshot() works on Firefox but not Chrome because ?
Do people here that use Selenium have a preference between Chrome and Firefox?
I've done all my stuff in Chrome until now, my one attempt at running one of my scripts in Firefox seemed to have it not waiting properly and trying to find elements while pages were still loading
But I certainly didn't give it much of a fair try
resources for web dev?
What is required to do to a web server to see updated content like your backend when you push a new update? Is it a restart of nginx or something else?
I guess by backend I mean if I clone a GitHub repository in place so the .py files are different than they were before. Do you have to restart nginx? Does disabling caching work?
if you have got the new .py files, restart gunicorn/whatever server you use
nginx is the just the reverse proxy so that makes no difference
caching could affect it; depends exactly what is being cached
Kk
need web developer urgent, not very deep pockets, still please help
We don't have a recruiting system here
If you're a developer yourself, feel free to ask questions about your issue
How does everyone feel about webscraping?
@wicked path I've read that question 3 times and it makes me wonder... is there a correct answer to it? What is the actual response you'd expect to receive? xD
webscraping is fine as long as the website in question doesn't prohibit it
I just want to know peoples mindset is regarding scraping that's all
I think it's cool
especially using python where it's made almost as simple as it could be
Anyone ever use wagtail or django based CMS?
for sure. don't ask to ask if you have a question
Hey what are the ways to send data between routes?
I am building a system to list products on a marketplace.
I have a route with a form for writing the product info. From that, it sends through a function to build a JSON file with that info, then I send it through their server to validate this json.
If it's valid I want to send to another route to confirm the post. My problem is that the JSON file is relatively big, and I create 4 versions of it, with different prices.
I tried to send it via session cookie(eg: session['json']). But the data is bigger than what is allowed, and if the user opens several tabs with different products, it'll overwrite the variable.
I then tried to save it to the database, but it'll also be overwritten if the user opens several tabs.
The only one working properly is sending the data via URL, but the URL is too long now, and makes it harder to debug.
Anyways, is there another (better) way to do it?
Oh, and I'm using flask
Cache?
You use the session cookie as a key component for a value stored in a caching server, memcached or redis or w/e
If you're not deploying to the masses, you can also just keep it in memory
Try Flask_Session
@stark yarrow ping since it was an hour ago
By default it will keep the server side session in memory
Just make sure you're not storing hundreds of MB of json
@queen needle Thank you. I will check it out!
anyone here who can help with authlib?
!t ask
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.
β’ 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
β’ Keep your patience while we're helping you.
You can find a much more detailed explanation on our website.
how can i make it work properly, im following the documentation and keep getting errors about missing tokesn etc
authlib.common.errors.AuthlibBaseError: invalid_request: A required parameter "client_secret" is missing
when i do
oauth.register('linkedin',
client_id='xxxxx',
client_secret='xxx',
access_token_url='https://www.linkedin.com/oauth/v2/accessToken',
authorize_url='https://www.linkedin.com/oauth/v2/authorization',
api_base_url='https://api.linkedin.com/v1/',
client_kwargs={'scope': 'r_basicprofile r_emailaddress'},
)
@app.route('/oauth/linkedin')
def oauth_login():
client = oauth.create_client('linkedin')
redirect_uri = url_for('oauth_authorize', _external=True)
logs.debug("Redirecting user to linkedin authorize url")
logs.debug(client.authorize_redirect(redirect_uri))
return client.authorize_redirect(redirect_uri)
@app.route('/authorize/linkedin')
def oauth_authorize():
client = oauth.create_client('linkedin')
logs.debug("Created client")
logs.debug(client.client_secret)
token = client.authorize_access_token()
which line does that error occur on?
i can pass client_secret to it by doing client.authorize_access_token(client_secret=client.client_secret) but that is not documented in anwhere properly,
but now, when i do
resp = client.get('people/~?format=json', token=token)
i get KeyError: 'token_type'
@meager anchor
can't really look into it right now but maybe the source can help you out, I think this marks the spot https://github.com/lepture/authlib/blob/ee4ae9c41c3b8bde16c8f2760e9c3d3f070d6524/authlib/client/oauth2_auth.py#L39
There's absolutely no way of doing the equivalent of await while in a callback that's not async is there?
async def pointless1():
print("pointless1")
await asyncio.sleep(2)
return 1
print("pointless1.1")
def pointless2() -> Task:
print("pointless2")
loop: AbstractEventLoop = asyncio.get_event_loop()
task: Task = loop.create_task(pointless1())
# There is no way here to wait until the task is complete and continue
# Exception:
#loop.run_until_complete(task)
# Invalid state error:
#task.result()
return task
async def pointless3():
print("pointless3")
task = pointless2()
# even here it can't be done.
print("pointless3.1")
loop: AbstractEventLoop = asyncio.get_event_loop()
loop.run_until_complete(loop.create_task(pointless3()))
why can't it be done in pointless3, @strong sonnet?
wtf, linkedin only allows selected partners that use their job listings to access the user skills via the api
@worn sapphire it's just an example. pointless3 might call a constructor which is pointless2. You can't make constructors async, so you're basically stuck
You really want the class to be fully initialized by the time init returns, but if pointless2 is and init then you're left with a partially initialised class.
Yes you can create a callback, but it gets messy.
why make pointless2 an __init__? it can be a factory function that returns an awaitable future like it essentially is right now
It's not always possible or practical to do that. Yes I guess you can redefine your entire code-base to make everything be async, but it doesn't always work out like that
Like... init functions should be the way to initialise a class. That's their entire purpose. You could maybe have an ainit function instead I guess, but having a factory method is untidy
hmm im having trouble with oauth2 again
im using the token i recieved after authneticating with authorization token but i keep getting The token used in this request has been revoked by the user
well i solved it
linked in cannot understand that some apps can use the token almsot immiteadly
by adding a small time delay of 5 secs it works perfectly
@strong sonnet
(a) it's always possible to wrap an object's creation in an async factory and I have a hard time believing it's frequently impractical
(b) who said anything about making everything async? this is only to address the case of the rare class that needs to be asynchronously initialized
(c) factory patterns are extremely common and in no way, shape, or form inherently untidy unless you've implemented them poorly
Hey guys, I got asked a question to review on my in-person interview: "What is your viewpoint on development flow?" What is development flow exactly? Like... agile development or scrum environments?
can someone help me with django? I have the form like
class UploadForm(forms.ModelForm):
class Meta:
model = Video
fields = ('title', 'video')
and view like
if request.method == 'POST':
form = UploadForm(request.POST)
print(request.POST.get('title'))
if form.is_valid():
return HttpResponse('test')
else:
form = UploadForm()
return render(request, 'upload.html', {'form': form})
and the problem is form.is_valid() is never true.
it always dumping my form with error under title - This field is required
Does anyone have experience with setting up multiple python sites in IIS using wfastcgi? I'm not sure how I properly set the PYTHONPATH variable for each without them colliding
good morning guys!
I'm looking for flask boilerplate(starter)
is there some recommendation?
https://github.com/sloria/cookiecutter-flask i like to follow the general structure of this when creating flask apps.
@brazen stirrup
@tame viper thank you for your recommendation
π
im trying to input multi-lined strings into flask templates, but the " ` " keeps getting through the safe filter. Is there a prevent it
if i try .replace it sanitizes the sanitize
from flask import Flask, jsonify
app = Flask(__name__)
@app.route('/simplecrypter/<string:message>/<int:key>/<int:choice>', methods=['GET'])
def s_crypter(message, key, choice):
alph = 'bILsNC3Jv1w2Vj6u4AhWMPDmBlQ7 rtKHZfEa9XFocpnY5eUGxdyzTkRSiO80qg'
newmessage = ''
out_message = {'message': newmessage}
for c in message:
if c in alph:
pos = alph.find(c)
if choice == 0:
new_pos = pos + key % 63
elif choice == 1:
new_pos = pos - key % 63
newc = alph[new_pos]
newmessage += newc
else:
newmessage += c
return jsonify(out_message)
if __name__ == '__main__':
app.run(debug=True)
I am learning to build APIs using Flask
I am getting an error of index out of bound for newc = alph[new_pos]
can anyone who has knowledge on APIs in Flask check this and point me what am I doing wrong?
You may want
new_pos = (pos + key) % 63
That way the modulus operator correctly works on the whole position and not just the key part
(Same with the pos - key line)
yes Now it works but returns an empty string
Oh yeah
i have to add it to the dict first
stupid me
π
thank You @pearl kite
Can i have 2 websites on the same server?
yes
@tame viper im confused why my second domain will not work
okay
server {
listen 433;
listen [::]:433;
server_name code.mcadesigns.co.uk;
location / {
return 301 https://github.com/Sharpz7;
}
}
server {
listen 433;
listen [::]:433;
root /var/www/mcadesigns.co.uk;
index index.html;
server_name mcadesigns.co.uk www.mcadesigns.co.uk;
location / {
try_files $uri $uri/ =404;
}
error_page 404 /404.html;
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
}
IMPORTANT NOTES:
- The following errors were reported by the server:
Domain: code.mcadesigns.co.uk
Type: unauthorized
Detail: Invalid response from
http://code.mcadesigns.co.uk/.well-known/acme-challenge/DoriRmKpGoGWkz_jrFo0uPDvKVX6v5l7pectxlNesPs:
"<!DOCTYPE html>
<!--[if lt IE 7]> <html class="no-js ie6 oldie" lang="en-US">
<![endif]-->
<!--[if IE 7]> <html class="no-js "
Domain: mcadesigns.co.uk
Type: unauthorized
Detail: Invalid response from
http://mcadesigns.co.uk/.well-known/acme-challenge/TUc4rHuuANSLQRjgbSVNyhMsM_llXV7N1LePtVDLoQA:
"<!DOCTYPE html>
<!--[if lt IE 7]> <html class="no-js ie6 oldie" lang="en-US">
<![endif]-->
<!--[if IE 7]> <html class="no-js "
Domain: www.mcadesigns.co.uk
Type: unauthorized
Detail: Invalid response from
http://www.mcadesigns.co.uk/.well-known/acme-challenge/5yB3RrojzdCFTgQzWJJmuAp0VULxRwa3zXwMGQyxNVA:
"<!DOCTYPE html>
<!--[if lt IE 7]> <html class="no-js ie6 oldie" lang="en-US">
<![endif]-->
<!--[if IE 7]> <html class="no-js "
To fix these errors, please make sure that your domain name was
entered correctly and the DNS A/AAAA record(s) for that domain
contain(s) the right IP address.
Running service nginx restart produces no errors
what's your domain configuration?
Wait a sec
I think a friend of mine
Smashed the wrong number
When i typed it in
hm
oh okay
@shrewd sand Did you get let's encrypt to work?
Are you visiting your website on HTTP or HTTPS?
your port 80 is closed
Oh, yeah, you don't have any listen 80s
Is that intentional?
And you canβt reach your server on 443?
xd
I mean
You're listening on 443, but don't specify certificates, clients won't like that
Ohhhhh
What
I added certs
Okay
dw
server {
listen 433;
listen [::]:433;
server_name code.mcadesigns.co.uk;
location / {
return 301 https://github.com/Sharpz7;
}
ssl on;
ssl_certificate /etc/letsencrypt/live/mcadesigns.co.uk/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/mcadesigns.co.uk/privkey.pem;
}
server {
listen 433;
listen [::]:433;
root /var/www/mcadesigns.co.uk;
index index.html;
server_name mcadesigns.co.uk www.mcadesigns.co.uk;
location / {
try_files $uri $uri/ =404;
}
error_page 404 /404.html;
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
ssl on;
ssl_certificate /etc/letsencrypt/live/mcadesigns.co.uk/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/mcadesigns.co.uk/privkey.pem;
}
Wait a sec
error_page 500 502 503 504 /50x.html;
502 is covered
π€
NGINX is running, correct?
Yep
The site is symlinked to /etc/nginx/sites-enabled?
Or my other domain wouldn't be up
sudo nginx -T outputs these configurations?
Can you try telling nginx to listen on 80?
Not sure
Did you follow this? https://www.digitalocean.com/community/tutorials/how-to-host-a-website-using-cloudflare-and-nginx-on-ubuntu-16-04
No
Lets not get into how long this took me to do the first time ;D
What i am saying is
Cloudflare automatically changes http to https
Ah, I see
Do you get anything popping up in your nginx access or error log?
@meager anchor got something
Disabled auto https
And listens to 80
You get this
What?
Where did you put that?
In an existing server block?
Can you try telling nginx to listen on 80?
server {
listen 80;
listen [::]:80;
server_name code.mcadesigns.co.uk;
location / {
return 301 https://github.com/Sharpz7;
}
ssl on;
ssl_certificate /etc/letsencrypt/live/mcadesigns.co.uk/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/mcadesigns.co.uk/privkey.pem;
}
server {
listen 80;
listen [::]:80;
root /var/www/mcadesigns.co.uk;
index index.html;
server_name mcadesigns.co.uk www.mcadesigns.co.uk;
location / {
try_files $uri $uri/ =404;
}
error_page 404 /404.html;
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
ssl on;
ssl_certificate /etc/letsencrypt/live/mcadesigns.co.uk/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/mcadesigns.co.uk/privkey.pem;
}
you have listen 80 and ssl on there
Yeah ok
433 gives a 502 error from cloudflare
So my main server listens 2 433
This one to 80?
In your case, make an extra server block:
server {
listen 80;
listen [::]:80;
server_name code.mcadesigns.co.uk www.mcadesigns.co.uk mcadesigns.co.uk;
return 301 https://$server_name$request_uri;
}
Add that
Then change 80 back to 443
in your other configs
A website to show of my skills in Python and as Owner of Sharpbot.
It works
Ill add your changes now ;D
Is that with cloudflare?
ah
@meager anchor what is that code actually solving
I don't see how it solves the problem
It was in response to you adding the listen 80 in the wrong spots, what I meant was to set up a redirect to https
But i don't need to do that?
server {
listen 80;
listen [::]:80;
server_name code.mcadesigns.co.uk;
location / {
return 301 https://github.com/Sharpz7;
}
ssl off;
ssl_certificate /etc/letsencrypt/live/mcadesigns.co.uk/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/mcadesigns.co.uk/privkey.pem;
}
server {
listen 80;
listen [::]:80;
root /var/www/mcadesigns.co.uk;
index index.html;
server_name mcadesigns.co.uk www.mcadesigns.co.uk;
location / {
try_files $uri $uri/ =404;
}
error_page 404 /404.html;
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
ssl off;
ssl_certificate /etc/letsencrypt/live/mcadesigns.co.uk/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/mcadesigns.co.uk/privkey.pem;
}
this is the config that is getting the server working
cloudflare is automatically converting to https aswell
ah
So why does it break, when i make the port 433?
Should i have everything in one file?
Idk
as to "why does it break" I'm not sure, check the guide I linked, there is a client certificate configured there
and "should i have everything in one file", thats up to you, i have one file per http / https per domain managed via ansible
Yeah
I just don't see why one domain is working
And one isnt
xd
When they have the same configs
@meager anchor followed that link
Set it all back up to port 433
Get the error.......
And the log is empty
;D
Really confused now.....
@meager anchor do i have 2 processes using the same port?
Is that the problem?
Sorry, I'm somewhat busy, if two services try to use the same port then one of them will break, and if your nginx doesn't blarg something like [emerg] could not bind you're good
is flask auto-converting strings to ints (if possible)?
hmm, how can i package a python flask app in a way that "normal" people can easily run it on their local machine
buy a domain :P
it's a webserver. you should serve it on the web.
but if you really must, I guess you'd have to make an installer or something.
Hey, I'm trying to build a form of a dynamic list of categories for product categorization. I'll be getting this information from a server dynamically. I'm trying to figure out the best way to do it.
eg: First the user selects a root category ('Eletronics, Sport and Fitness, Beauty, ...'). Then if it has children categories, I need to create a new list of values, with its children.
For example, if I select Eletronics create a new list with 'Smart TV', 'Home theather', 'Sound System', etc. Then if the new chosen category has childrens do it again until it doesn't return more categories. This will all be pulled from a json file provided by the request to the server.
I'm using Flask but I guess it wouldnt work but I still need to be able to retrieve the post data in Flask. I could do this using JavaScript but I don't how would I do it properly.
Because I'm dealing with over 150 thousand categories and subcategories I don't know the best way to handle this.
Can anyone give me a direction? I have a picture of exactly what I want.
use django
stick with flask if you prefer it
@naive wing depends on what you want to do. I don't think that flask has something built-in for that. You might be able to use something like at or cron. would be good to get some more info
@native tide your "answer" is absolutely useless. if you plan to help, provide some useful information, django does not have any built-in way to schedule tasks and even if it had, your message doesn't provide any useful arguments that would help in solving the original question
When i want to do web dev with python should i just dive right in django or somethig else. Or learn python itself first?
And is django for example able to make a Full website without any other language?
you should learn Python itself before taking on a bigger project, yes
depends on what you define as a "full website"
for front-end you generally need at least HTML
@native tide if you want to make a website with a python framework, you should probably learn python first
heyooo
anyone in here a react guru? or even moderately good at react? lol
I mean I know this is a python channel but if it helps this is in a django application w/ a react front end π
Don't ask to ask
Sorry .. it's just a lot to type out in a python channel if there's no one here familiar w/ react that's all.
This is just one of the more active discords and I know developers tend to be multi-disciplined lots of times.
What is the correct way to layout a navigation menu if i have html <header> <nav> <ul> <li></li> <li></li> </ul> </nav> </header> and want each li element to be a full on box to be clickable
Do i put the link tag inside the list element with a span or something to set the boundaries, or wrap each list element in a link tag
I found trying to style a link tag a with a clickable box... to be weird
While im at it, is it more semantically correct to have a logo/gotohome-image be within nav, or just header
I think either way is fine - logo in header or in the navbar
generally i dont bother wrapping the nav in a header element
I have only found it to be redundant in my experience
I thought i'd create a generic nav bar template i imported to all other templates
but I suppose it depends on your design
So figured i'd do it as correct as possible to just be.. correct
And if i put the logo outside of nav, header kind of makes sense
<header>
<img src="static/logo.png">
<nav>
<ul>
<li></li>```
I'll just do that
Any idea on a good practice for nav bar <a> tag placement though?
There really is no correct way with these semantic tags imo
True, but it does effect the google algorithm
there are various combinations which all can make sense
well that's a different story
Stuff like just having a header tag bumps you up quite a bit.
So i just kind of want to make it a habbit
I only use is if I really need it as a list. I usually just go with divs or spans at that point
May I ask, do you really need a ul for your navigation?
sorry my internet is cutting out π‘
where it seems like a list, a ul/ol makes sense
The web design course I'm taking heavily focuses on correct semantics as well
So stay away from divs
Ordered lists are better for navbars
and spans for inline styling
In my opinion
Any particular reason to why?
I mean, sure.. It is ordered in a sense
But it's order does not matter(?)
God I have a feeling this course is going to hurt me in the end 
Proper semantics is great and all but I don't think the list elements suit navbars very well. Unless it's vertical and you're not hiding the bullet points. Even then, I feel like the lists should be reserved to text most of the time
But it has pweddy liddl numbers
Point of the list is to the semantics of showing, things are listed in some fashion here.
But.. eh
A list was correct according to my lecturer at least

If you Google around on whether or not you should use lists as the markup for navigation on websites, you'll find no debate. Every article suggest that
I like the alternative
where you just have the anchor elements directly in the nav
much cleaner looking
the list just feels completely redundant
it's just a dummy wrapper around what you actually want to display
Main thing to take away from this is that there isn't a set in stone way of doing things
True
as you can see there are various arguments for how to do this
But I do want to do what pleases the lecturer the most 
<script>
var as = true;
</script>
I keep on doing the python at the beginning
Sorry
But no scripts!
That's appauling
They are easier though
Never found it easier, nor cleaner
Clean - Ness is an issue
view-source:http://www.galehuset.org/
I was never taught how to import
Copy paste the line, it's the project for my last web dev course
But that is owing toe self teaching myself
@olive wharf By the way what do you find weird about styling an anchor as a button?
Like implementation wise
or semantically?
The part where I specify width and height on the <a> tag it self
It didnt seem to actually gain the height, nor width
I self taught myself python, c#(didn't want to, but Unity was like heyyyyyyyyy), js, java, Pascal and a bit of c++
I've managed to successfully do it
Only if i wrapped it in, say a div would the entire block act as a link
I believe i did as well
here's is what I had html <nav> <a href="" class="nav-link current" id="nav-link-1">Item 1</a> <a href="" class="nav-link" id="nav-link-2">Item 2</a> <a href="" class="nav-link" id="nav-link-3">Item 3</a> <a href="" id="button-close">β</a> </nav>
<li class="project">
<a class="projectLink" href="project1/sub-directories/natalie.html">
<figure>
<img class="projectImg" src="visuals/treehouse.jpg" alt="broccolitreehouse">
<figcaption class="projectCap">Lab 1. - Fun Facts</figcaption>
</figure >
</a>
</li>```
i what I have for https://dikult105.k.uib.no/2018H/students/tpe044/
Wait..
Nvm?
I was sure I ended up with the a outside of the li tag
looked like
Couldn't you use a <form> <input type="button" id="egid"> </form>
lol no
For examplw
you wouldnt use forms for nav bars
Forms isnt really made for navigation bars :v
pls no spam
@olive wharf ok for your site it's different cause it isn't just a simple nav bar
I wouldn't only use an anchor there obviously
True
Even though it can work
But i had issues with the entire block being a link
wait, no that was project 2
ah yeah
<nav>
<ul>
<li>
<a href="#">Series</a>
</li>```
Where only text is click-able
π€’
c ya
Wait for it
I remember I also encountered that issue
there is a fix for it, just dont remember it
Guess ill look for that then
Send random people friend requests
some way to change the clickable area for the anchor
I'd hate to wrap list elements with a tags
But I am questioning one thing about the post you sent btw, mark
and that would be'
Does this say.. it made it better, or worse for screen readers
Cause that's pretty much the edge case here
Not sure either
And i should stop reading things from end to start
Lol
post above basically explained it
if it just reads it like that..
See no point
yeah
Shame I can't use any form of scripting / backend tools for the course
But this gives me a bit of practice at least
Just read an interesting thing
If your logo links to e.g. the home page
it'd make sense to put it inside nav
otherwise, don't
since it doesnt navigate the user to anything
The nav element represents a section of a page that links to other pages or to parts within the page: a section with navigation links.```
discussed it an hour ago with a class mate as well
Doesn't look like you have it linking to anything
not yet, no
Then so far, I'd say you did the right thing with the header
I'll still keep the header
if it's clickable I'd move it inside the nav bar
π€
easier to copy paste π
... does that help me? lol
it's fighting my case
https://webaim.org/techniques/screenreader/ Seems like a worthwhile read at least
Yeah
That's what I ment
Maybe I'll use header as .. the head of the sites content
like
nav
header
main
footer
Anywho thanks for your time @proper hinge Imma hit the hay
gn
what does reqparse do in flask
Flask doesn't have anything called reqparse
Do you mean this? https://github.com/smitthakkar96/flask-reqparse
ahh it's in flask-restful nvm
anyway, i was wondering what would be the best way to check if a user who is sending a POST request's json file is in the right format
I want it like this
{
"username": "mushy"
}
anything else it would reject and return a 404
on flask btw
add a list of expected fields and if one is not there, raise a NotFound or BadRequest exception
(also, don't return a 404, that's for when they try to access a page that doesn't exist)
422 might be a good one, though 400 is also fine (but too broad imo)
if you are looking up a user (which that request body might be doing) 404 should be fine
yeah I was looking up a user
in that case, 404 is appropriate
but a bad POST request format calls for 400/422 does it not?
add a list of expected fields to what
hmm actually
it might be the one yeah
a list of expected fields in the POST request
https://pythondiscord.com/api/ uses schemas but idk where they're from :D
we made them
oh huh okay
i think
@app.route("/search", methods=["POST"])
def search():
expected_fields = ("username",)
for field in expected_fields:
if not request.json.get(field):
raise werkzeug.exceptions.BadRequest(f"The required field, {field}, was not found in the request")
something along the lines of that
I just threw that together in Discord so I can't confirm it works
yeah, something like that ought to do it.
yeah I was thinking something like that
but if you do that a lot, i recommend putting it in a decorator like we have
but i would have to do that for every endpoint right?
if you are using it across requests it wouldn't be hard to put that into a decorator
Oh yeah you are right juan, schemas are from https://pypi.org/project/schema
also, when doing
request.data
it just returns an empty byte when printing
but when I do request.get_data().decode('utf-8) it returns it normally
whys that?
well
whats the difference between request.data and request.get_data()
is a better question
"request.data Contains the incoming request data as string in case it came with a mimetype Flask does not handle."
yeah, if the data has been parsed (e.g. placed into request.json) I don't think it appears in request.data
which is.. not good design, imo
It is a little odd
inconsistencies make me upset
oh so I should be able to access it with request.json
certainly
naisu
if the data is json, request.json will be a dictionary
yeah it's a json
nah, get the error sorted now while you can
what error might be thrown?
wait, doesn't flask do it already
I think 400 should be used for not json
ill check actually one sec
oh hmm
because 422 suggests that the syntax is correct but the instructions could not be carried out
400 suggests that the request is invalid
yeah, but looking it up seems to show that the syntax is valid for 422 errors, it just can't be processed
but really, 400 can work for all 4xx errors, it's just broad
it's the Exception of exceptions

yeah
"sorry, i don't know how to say this, so.. 400 Bad Request"
what's the highest status number a HTTP response can have?
oh hm
so i used request.json
and it's returning a nonetype now
omg
nvm im an idiot
oh hey, that makes two of us
Good evening. In which Channel can i post question for discord api?
oh yikes, gotta fix up the schedule school opens soon π
questions about using discord.py can be asked in the dedicated channels, but if it's a general question about the discord API then here should be fine
@native tide
Okay so I should retun 403 forbidden if they dont have a token in their header, and 401 unauthorized for wrong token
401 for both
i believe
403 is when they try to access a file that the server doesn't have permissions to view, for example
@kind steppe can you confirm?
I can't remember exactly
One of them is you'll never have permission, one is that you aren't logged in iirc but i may be wrong
401 means authentication is possible but has failed or not been provided
403 means server noticed request but won't respond to it even if you provide login credentials
HTTP status codes and how to use them in RESTful API or Web Services.
That's the one
finished my forum software π
Can i have global templates in django?
If i wanted to create multiple apps, with their own respective templates etc, and have them all inherit a global navigation bar from the main projects templates
Yeah!
I'm doing exactly that in our django rewrite
Basically, by default the template loader looks for the app paths
However, you can add the projects path or whatever else you like
Ay yeah I figured out through a bit of trial and error c:
Ah that's the magic
but yeah, It generated a templated folder in the projects dir so I plonked by base template there, and could use it anywhere in my apps
actually... is it working? 
<body>
<nav class="nav-bar" role="navigation">
<img id="logo" src="static/logo.png" alt="Logo of website">
<a class="nav-element" href="/">Home</a>
<a class="nav-element" href="/projects/">Projects</a>
<a class="nav-element" href="/blog/">Blog</a>
<a class="nav-element" href="/about/">About</a>
<a class="nav-element" href="/contact/">Contact</a>
</nav>
<header>
</header>
<main>
</main>
<footer>
<span>Copyrighted © Floppy-Mc. Flopson</span>
</footer>
</body>
</html>
<h1>Hello</h1>``` I got this
from doing this ```html
{% include "base.html" %}
{% block header %}
<h1>Hello</h1>
{% endblock header %}
with a base like this html <header> {% block header %} {% endblock header%} </header> <main> {% block main %} {% endblock main %} </main> <footer> <span>Copyrighted © Floppy-Mc. Flopson</span> </footer> </body>
Uh~
What's the difference of include and extends here?
You have a base and a navbar template?
Include just ... includes the thing
Extends allows you to change blocks and whatnot
I have a base which is basically navbar + footer with blocks for header and main
Oof, i probably want extends then
Ah yeah, there we go
Didn't need super c:
just the mistake of using include over extends
no sir
so where does the pages app come from?
@tame viper having trouble writing the decorator to check the fields
I haven't written a proper decorator before, but I have this so far
def parse_fields(expected_fields):
def field_decorator(func):
def func_wrapper():
print("Called fuction wrapper.")
data = request.json
for field in expected_fields:
if field not in data:
return BadRequest(f"The required field, {field} is missing.")
return func_wrapper
return field_decorator
and trying to call it in my route like so
@app.route('/api/v1/user/', methods=['POST'])
@parse_fields(["username"])
def user_info():
data = request.json
user = User.query.filter_by(username=data['username']).first()
if user is None:
return BadRequest(f"That user does not exist.")
user_data = {
"uuid": user.id,
"username": user.username,
"email": user.email,
"first_name": user.first_name,
"last_name": user.last_name,
"last_seen": user.last_seen,
"about_me": user.about_me
}
return jsonify(user_data)
@meager anchor ya sir i created it using startapp command
ok. can you show us the migration?
Anyone have any ideas?
The decorator works for the most part, as when I enter an incorrect field in the JSON post request, it picks it up and throws a badrequest
how can i show sir
however, when it's correct, I get this:
TypeError: The view function did not return a valid response. The function either returned None or ended without a return statement.
you never actually return the result of the function in the decorator
try
def parse_fields(expected_fields):
def field_decorator(func):
def func_wrapper(*args, **kwargs):
print("Called fuction wrapper.")
data = request.json
for field in expected_fields:
if field not in data:
return BadRequest(f"The required field, {field} is missing.")
return func(*args, **kwargs)
return func_wrapper
return field_decorator
what would this do?
where i can find those migrationns
I just want it to check if theres a bad request, if there isn't then the view function can continue
ill try this though one sec
yeah that worked @meager anchor thanks, could you explain what that did? if you dont mind
@raven harbor pages/migrations
@hearty birch your code replaces your original request function with func_wrapper, which returns None if all fields are present
and flask expects responses to be returned
well, a view gets called in response to someone visiting a URL
what would you expect a view to do?
no i mean the decorator, why will it not just continue with the function instead of returning None
because you don't call it
ah ok
say I have a backend in Flask and frontend react, how would I handle things such as logging in?
There are many ways to deal with layout in CSS. One solution is to set the cards to have a display: inline-block property
@knotty lark can u edit a lil bro so that i can understand.. please
Do you know CSS at all?
you can add display: inline-block; to the style tags of your cards and it should do the trick.
but im new to this ide and pythoon codes so.. feels unusual bro
okay ill do that and get back to u in a min ....bro
I'm not your "bro". Does pages/migrations/__init__.py contain anything?
@knotty lark thanks for the idea .. it worked
@meager anchor sorry if that was wrong please tell me how can i address u with
@meager anchor nothing it is empty
you gotta migrate your app before you can run it properly
Ah, i've run into a problem with the decorator
if I use it for another route
AssertionError: View function mapping is overwriting an existing endpoint function: func_wrapper
i used ---> python manage.py migrate this is the only time i used migrate command
@meager anchor is there any command that i need to use to fix it..?
so it's thinking that func_wrapper is an endpoint function π
yeah I can't get this to work
Can anyone here help me with something?
im stuck on it and ive tried everything.
tag me if you can
!t ask
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.
β’ 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
β’ Keep your patience while we're helping you.
You can find a much more detailed explanation on our website.
nvm i fixed it
stupid error
didnt indent
lol
When I try to delete a entry from my model I get this 'bool' object is not callable
any ideas?
How are you trying to delete it
Show us the code..
name = models.CharField(max_length=30, unique=True)
description = models.CharField(max_length=100)
def __str__(self):
return self.name```
Thats my model
I got it.
@raven harbor It's functionality provided by the bootstrap template you're using. On smaller resolutions the menu bar collapses into a drop down.
but previously it was working fine is there any way to bring them back in position
lol sorry for my stupidity .. those are completely new for me...
Ignorance != Stupidity π that's how you learn 
can u suggest me any tutorial to learn using bootstrap and font-awesome on django..
Well they're seperate topics from django, just visit the bootstrap website and the font-awesome website π They're just things you use in your client side html/css
But the code is different than normal html page to python html page so im confused.. I hope soon I'll learn
Well, there are some embedded statements in it because you're using a templating system but it's still just regular ol' HTML outside those {% %}s
I think there might be "helper" modules for bootstrap on Django just like Flask has the (outdated) flask-bootstrap
Google will tell
is there a difference between flask.escape and flask.Markup.escape
Tias?
? cant get u ...
Try it and see
It didn't bro I got a white screen then nothing happened after refresh I got my page normally
how good is python for the backend of websites
if u mean django/flask, it's good
@patent aspen mind-blowingly good
even besides django/flask there are several valuable web frameworks depending on your needs: aiohttp, tornado, falcon, hug
please help me with that preloader code
@idle osprey flask.escape is pulled from jinja2 which in turns imports it from the markupsafe module.
Markup.escape is basically a wrapper around the markupsafe.escape function as its docstring says:
@classmethod
def escape(cls, s):
"""Escape the string. Works like :func:`escape` with the difference
that for subclasses of :class:`Markup` this function would return the
correct subclass.
"""
rv = escape(s)
if rv.__class__ is not cls:
return cls(rv)
return rv
(might as well add the whole code)
@queen needle Cool! Thanks
okay thanks..
@raven harbor ur welcome. come back next time with useful information and we may be able to help.
sure im learning python from 2 days and i need to konw lots of infos from u all ill be back when i stuck with anything complicated
i dont have idea what you said, but the code you posted was css, not pythoh
im new to python and i need to know lots from u all
may i know that can i use sql server with python ? or any specific database to use
you want to know what database you can use?
S sir
any of 'em, pretty much
Last time I tried MS SQL Server with python, the modules worked "meh" and didn't support all the features, so I wouldn't recommend that one
For the rest, MySQL, postgre, mongo, all work finely so break a leg
It was 3 years ago but I wasn't satisfied with either pymssql or pyodbc
Then I'll stick with my SQL ..
By any chance can I view my website in my phone .. while developing itself..like local hist
Host*
run the site on 0.0.0.0 instead of localhost or 127.0.0.1, then connect to your computer's local IP from your phone. it must be on the same network though.
π€
do i need to include the app? (django) i ran the program with including and without including and both worked..
is that an app you created yourself? @native tide
oh i see that you are following thenewboston's django tutorial
include it
yeah.. i do
Ok now i know why i need to include it
because if i do not it won't be read by the database and the thing won't show up on the website
but thanks! @grand badge
np
i cant find login page on my screen where i went wrong ..i think i missed some python code
not exactly super helpful, you should post the backend code
why is your file icon /*
sorry to ask but can u please tell me how to find backend code and whats it?
i got it i was missing {% block conent %} now its fine
if you dont know what your backend code is, how on earth did you get that to run?
im learning things now and ill soon understand things like this situations
so i wanna use python for back-end but javascript for small scripting stuff, so im not sure how would i connect the python stuff to the front end html, would I do this with django or idk.. i'm experienced with HTML and CSS stuff but idk where to start for the back-end and how to connect it
django, flask, sanic, aiohttp, the standard library http.server...
all of these are viable options, which you pick will depend on the particulars of your project
http.server is great for playing around with simple request handling and building it yourself from the ground up, Flask is a very well-documented framework that makes routing and handling various kinds of requests very easy
Django is a much larger (and we often call it "more opinionated") framework but if you'd like to start with it it's also very well documented
someone told me (idk if this is true) but u can connect python to node.js
or something..?
is that true xD
I'm sure there's a myriad of ways. I don't see why you'd want to do that in the general case
all of these still use HTML, CSS, and JS right?
they're just HTTP servers, they don't care what kind of file they server
oh
hmm the problem is i dont know which one to pick xD
but yes, all these frameworks have mechanisms for sending that across, and some have templating engines for generating HTML
well, what's your project?
its like a multi-purpose website
like to show what i've made
login system to sell stuff
maybe stats from other APIs..?
my personal recommendation would be to start with Flask, then
and whys that? just asking so i could learn more
it's very easy to get started, it's got so much documentation it's not even funny, and it can be connected easily to robust server software like Apache and Nginx
what about the other ones? can they do the same?
Django is not as easy to get started with, but yes. Sanic and aiohttp are both asyncio-based and therefore probably not suitable for someone just getting started, but also yes
and those are just the ones I'm most familiar with
there's other stuff out there
Flask, though, is really the golden child of beginning web development, and it's even professionally viable
I don't think you'd regret working with it
π
I'm not sure what you mean by vid, but if you mean to show off your work, I feel like building a website is more development relevant than a video
plus it's very easy to update a website and a little harder to update a video
sure
so while looking at the flask documentation whats the difference between a module and package
Just as a heads up Corey just uploaded a huge video series on Django
oh that's right! have you seen any of it?
oh
its like java
why didnt i think of that
so when i create a package would i put in __init__.py would it just be like all the pages or what
i just want to have good practices with Flask and stuff @neat nest
!t
Β» ask
Β» classmethod
Β» codeblock
Β» enumerate
Β» except
Β» f-strings
Β» global
Β» iterate_dict
Β» listcomps
Β» no-dm
Β» or-gotcha
Β» pep8
Β» resources
Β» traceback
Β» with
Um! Hi! I've been developing a small CMS with flask for me and two other people to use, it has posting, searching, and a WYSIWG editor for the two people who didn't work on the code side of things. I wrapped up the app and tried to set it up on digital ocean using NGINX and Gunicorn, but it seems like my search method [Elasticsearch] isn't working at all, even though it's on the VPS and running. However, that's not my only problem, logging in doesn't save across pages on the VPS, but it does in the development environment. I'm not sure what's going on, honestly. I'm not getting any console errors on the droplet, and I'm not sure if NGINX is throwing errors because I don't know where to look for those.
Everything works perfectly in the development environment, so I'm not sure what to do.
for some reason when i open my __init__.py it doesnt use the stylesheet but when i open my index.html it uses the stylesheet
whys that
Where are you linking your stylesheet?
i put it in the same place where my html file is @raw seal
what framework are you using? @elfin trench
@elfin trench It seems you include static files incorrectly so server can't find them. Check you browser console for 404 errors for static files. Also I would recommend flask mega tutorial for you https://blog.miguelgrinberg.com/post/the-flask-mega-tutorial-part-i-hello-world It is better for beginners and still provides information about best practices. I think flask quickstart requires a little more experience in web-development and web-frameworks
@knotty summit i got that but now my CSS file can't get a image
and i have the image in the static folder
btw im using Flask
Is there anyone here who wouldnt mind helping me with dynamic fields in wtforms within a flask app?
Hi i'm using wtforms, i want a DecimalField to be separated by comma, not dot. I guess I have to insert number_format but I don't get how
@native tide i don't know about wtforms but maybe look for locale based features
i cant change the logo of a template .. the same logo remains after deleting the logo from the location .. what may be the reason. it works fine in html file but when i use this in python that problem occers
@native tide https://wtforms.readthedocs.io/en/stable/fields.html look for use_locale it mentions 'babel' needs to be installed
@raven harbor did you restart it?
no please hold on ill tell u after restarting
i meant just restart the python script, not your computer
maybe also do a hard reload in your browser
(shift-f5 or ctrl-f5)
find . -name lg.png and file $path
It may not be at that path
or it may be broken
ya its in path
no problem with that file
i found something that i cant keep new logo which i add to the folder but i can keep existing file in the folder without any issue why is it so
Is it being served with a bad MIME?
ah wtf why why hasnt my dns updated in 2 days?
@polar wasp I figured out that there isn't a way to do that. I had to manually change it
I have a model in django
And I'm ordering it by some field like
Title.objects.get(whatever).entry_set.objects.order_by('points')
Everything is good so far
From this query set
I want to have the object that has pk=x
The previous of that object in the same order
And the next in the same order
So long story short
Title.objects.get(whatever).entry_set.objects.order_by('points')
is the query set
Entry.objects.get(pk=5)
``` is the object
I want the next Entry object inside the queryset relative to the object I have
I'm not sure what I asking for
I can't make it more clearer
That's just a query set
I want to have the next item in a query set given an item as reference point
[1,3,8,2,7,0] and given item 2, I want to get 7
you could do limit 2 and go from there?
I've never heard of that
Is that queryset.limit or something like that?
Oh just getitem syntax
But then I can't know if the object is in that part or not
can anyone recommend me a good tutorial on how to get started with the backend of websites using ptyon
python*
thanks

which would u recommend, flask or django
They serve slightly different purposes, django while is giving you lots of tools you need out of the box has little options in which where you can make it more customized
To customize it, you need to work harder than you'd in flask, but in flask you can't get a huge website up and running as fast as in django
But in total vibora is faster than both, but is async so you need to know async

Rewriting my question
Title.objects.get(whatever).entry_set.order_by('points')```
from this query set I want to get the next object after `Entry.objects.get(pk=x)` and the object is definetly inside the queryset
what is x? the ID of the first thing returned by that query?
Not the first, just a random one that sure is inside the query
The actual query is something like
def _get_queryset(self):
entry = Entry.objects.get(pk=self.kwargs['pk'])
self.entry_cache = entry
queryset = entry.title.entry_set.order_by('points')
return queryset
def get_object(self):
return self.entry_cache```
And as extra context to the template, I want to include the next and previous entries inside that queryset
this is the actual html code.. and i can change images in this
this is the python code and here i cannot change images
the image that works with html is not appearing in python.The images came with the template only apearing
even i delete them in the source its appearing when i use the name of the file
Hey guys, i have the: base.html
and inside of it there's a code in the middle of the page with:
{% block content %} {% endblock %}
I have my index page with this code with jinja:
{% block content %}
<div class="gtco-section border-bottom">
<div class="gtco-container">
<div class="row">
<div class="col-md-8 col-md-offset-2 text-center gtco-heading">
<h2>Artigos</h2>
<p>DescriΓ§Γ£o sobre seus artigos.</p>
</div>
</div>
{% for post in posts %}
<div class="row">
<div class="col-lg-4 col-md-4 col-sm-6">
<a href="images/img_2.jpg" class="fh5co-project-item image-popup">
<figure>
<div class="overlay"><i class="ti-plus"></i></div>
<img src="images/img_2.jpg" alt="Image" class="img-responsive">
</figure>
<div class="fh5co-text">
<h2>{{ post['title'] }}</h2>
<p>by {{ post['username'] }} on {{ post['created'].strftime('%Y-%m-%d')}} </p>
</div>
{% if g.user['id'] == post['author_id'] %}
<a class="action" href="{{ url_for('blog.update', id=post['id']) }}">Edit</a>
{% endif %}
</a>
</div>
{% if not loop.last%}
<hr>
{% endif %}
{% endfor %}
</div>
</div>
</div>
{% endblock %}
And when i run, i get this erro:
jinja2.exceptions.TemplateAssertionError: block 'content' defined twice
When i use: {% block page_content%} {%endblock %}, work but the style looks...
Anyone please can help me?
mark me if answer
Iv completed my template and now I don't know where to start , I need to make a login using database . Can anyone help me with a link or an example file please that will mean the world to me
which web framework are you using?
Django
use the built-in authentication system
Can I use sqlite in django to run a shopping site ?
To access my login page I wanna create a new python file as login.py to code them into database?
sqlite and django are just tools to get something done, your question is like βcan i use fork and knife to eat saladβ
yes, you can, and your second question is incomprehensible
How can I make login process done . Now I just have html file ,how can I link python to it . It may be hard to explain. Can u send link to any video or a blog where I can learn
I searched many I can't find the apt one
So im pretty new to this and i was just wondering what people mean by add this file to your "working directory"
working directory usually means the folder you're currently in
like the folder you run code from and whatnot
In computing, the working directory of a process is a directory of a hierarchical file system, if any, dynamically associated with each process. It is sometimes called the current working directory (CWD), e.g. the BSD getcwd(3) function, or just current directory. When the pr...
2 popular libs for website development are Flask and Django (although there are others, such as sanic and vibora)
I would suggest looking at Corey Schaefer's tutorials on YouTube about Flask and Django
This is assuming you have a moderate knowledge of python already
Thank you.
I think we need to pin an explanation of the differences of flask and django in this channel because it keeps getting asked

@native tide need ur help
if you just started with python i suggest you learn the basics of the language first before you move onto web development @raven harbor
!t resources
It can be difficult to know where to begin when you are first starting out with Python. On our website, we have compiled a list of both free and paid resources that we recommend for learning and mastering Python.
It is hard to say exactly where you should start, as everyone will have a different prefered method of learning, but whether you like video tutorials, books or courses, you should find a suitable resource on our resources page
why wont my CSS image load? im using flask btw
the image is in my static folder too
@import url("https://fonts.googleapis.com/css?family=Roboto");
body {
background: url("{{url_for('static', filename='/imgs/background.png')}}");
margin: 0;
font-family: "Roboto", sans-serif;
}
.navbar {
display: flex;
justify-content: center;
align-items: center;
position: fixed;
width: 100%;
}
.navbar div {
display: inline-block;
margin: 27px 0 0;
}
.navbar div:not(:last-child) {
margin-right: 30px;
}
.navbar div a {
text-transform: uppercase;
font-weight: bold;
color: rgba(0, 0, 0, 0.7);
padding: 12px;
text-decoration: none;
font-size: 15px;
box-shadow: 0 0 20px rgba(0, 0, 0, 0.3);
background: #fff;
border-radius: 5px;
transition: all 0.25s ease;
}
.navbar div a:hover {
color: rgba(0, 0, 0, 0.4);
transition: all 0.25s ease;
}
.navbar div .active {
color: #000;
}
#splash {
min-height: 100%;
display: flex;
justify-content: center;
align-items: center;
}
#profile {
box-shadow: 0 0 50px rgba(0, 0, 0, 0.3);
}
#profile, #title {
display: inline-block;
}
#profile {
width: 200px;
border-radius: 50%;
margin-right: 15px;
}
#title {
margin-left: 15px;
color: #fff;
}
#title h4 {
font-weight: 100;
color: rgba(255, 255, 255, 0.7);
}
#title h1, #title h4 {
margin: 0;
}
^ is my css code too
url("{{url_for('static', filename='/imgs/background.png')}}");
i dont think jinja2 works in .css files
<link rel="stylesheet" type="text/css" href="../static/nav.css">
yea
and make sure this is in your html
huh now it works
and rename the css file to whever it is
<html>
<head>
<title>SoulSen - A Developer</title>
<link rel="stylesheet" href="{{url_for('static', filename='assets/css/indexstylesheet.css')}}"/>
</head>
<body>
<div class="navbar">
<div><a class="active" href="#">Home</a></div>
<div><a href="//somewhere">Minecraft</a></div>
<div><a href="//somewhere">Applications</a></div>
<div><a href="//somewhere">Login</a></div>
</div>
<div id="splash">
<img id="profile" src="https://i.imgur.com/JjcWXJF.gif">
<div id="title">
<h4>Hello, I am</h4>
<h1>SoulSenGaming</h1>
</div>
</div>
<script src="{{url_for('static', filename='assets/js/scripts.js')}}"></script>
</body>
</html>
thats my html
from flask import *
app = Flask(__name__)
username = 'This Is A Person'
@app.route('/')
def index():
return render_template('pages/index.html')
if __name__ == '__main__':
app.run(debug=False)
__init__.py
ok
all good?
np
Ok now I have a question for someone if they could help me out?
I'm helping a college prof out by creating some web application for him. It's something to do with electrical engineering, but just wants to record data. He has given me these requirements:
At the home page, there is one form, a text field and a submit button. This form creates a new page and uses what was in the text box as the title.
The navigation bar updates with the page that was created (THIS IS DONE)
On the pages that are created, there is one form that has a dynamic number of fields. This is where it gets tricky for me. He wants to start out with one empty text field and a button that says "Add Note". So when you click this button, it adds a new empty text field. The page also has a second button that is for saving the notes. (THIS IS DONE)
What I don't know how to handle is the generation of new pages. I can certainly add text to a navbar when a form is submitted, but not sure how to keep generate a new page and then view it dynamically. One thought was to literally create a new file page1.html and add in html and jinja2 code in a method somewhere. I can easily create a file and add some text do it, but didn't know if I'm overthinking this?
also one more thing i know this isnt a CSS discord but how would i make something happen on click of a image?
that's not really css
You'd need to look into dom events
If the result you want from the click is a change in CSS you can perform that change from the script by either adding styles to the element or adding a class
oh okay
well for my website

