#web-development
2 messages · Page 9 of 1
Instead of registering it into the contrib.auth app
I'm just gonna use this as a separate app called user and put my models in another app and just remove the Group all together
did you migrate when you set AUTH_USER_MODEL?
I deleted the database
And did my first migration with auth user set
Yup went with that
Thank you for trying tho :D
I installed Django because it was bugging me. Couldn't get it to work :D
one possible solution might be templates
Hey guys, any suggestion for good and free course and/or tutorial for Django? I'm doing one from official site at this moment, but i could use something more detailed and begginer friendly 😃
I found the one on the site to be pretty detailed..
@gritty carbon what issues did you face when reading through it?
@stone vine thanks mate will check them out for sure
@meager anchor i don't understand templates syntax and why we are passing values to them in form of dictionary, that's the first thing for example. I have no problem recreating steps in that tutorial but i don't feel that i'm really understanding all concepts
Templates get values in dictionaries because that's the simplest way to associate a variable in the template with a value from your python code
Hello fellas. I am in need of some asistance with SOAP ws and python. If someone knows anything about it, please, would you kindly help me? This is my case.
I'm trying to send an XML envelope file to a SOAP WS using python
Notice that the WS i want to consume is public and has the following tree structure.
So i just want to consume the sendBill method from that WS
for this i have tried about 3 different libraries. Being zeep the most recommended on StackOverflow and the one that looks like might solve my problem.
But with zeep, it looks like all i need to do is sent the variables to the parameters the method requires. Which is actually wrong, since the XML envelope you get when analyzing that public ws looks like this.
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ser="http://service.sunat.gob.pe">
<soapenv:Header/>
<soapenv:Body>
<ser:sendBill>
<!--Optional:-->
<fileName>?</fileName>
<!--Optional:-->
<contentFile>cid:872654575379</contentFile>
<!--Optional:-->
<partyType>?</partyType>
</ser:sendBill>
</soapenv:Body>
</soapenv:Envelope>
but the ws actually wants a xml like this
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:ser="http://service.sunat.gob.pe" xmlns:wsse="http://docs.oasisopen.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
<soapenv:Header>
<wsse:Security>
<wsse:UsernameToken>
<wsse:Username>20100066603MODDATOS</wsse:Username>
<wsse:Password>moddatos</wsse:Password>
</wsse:UsernameToken>
</wsse:Security>
</soapenv:Header>
<soapenv:Body>
<ser:sendBill>
<fileName>20100066603-01-F001-1.zip</fileName>
<contentFile>my-zip-file-encoded-base64</contentFile>
</ser:sendBill>
</soapenv:Body>
</soapenv:Envelope>
so i need to send an entirely XML to that ws instead of just filling the parameters from the method i want to use
for that i have found this example (from StackOverflow) on python
import requests
url="http://wsf.cdyne.com/WeatherWS/Weather.asmx?WSDL"
#headers = {'content-type': 'application/soap+xml'}
headers = {'content-type': 'text/xml'}
body = """<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:ns0="http://ws.cdyne.com/WeatherWS/" xmlns:ns1="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
<SOAP-ENV:Header/>
<ns1:Body><ns0:GetWeatherInformation/></ns1:Body>
</SOAP-ENV:Envelope>"""
response = requests.post(url,data=body,headers=headers)
print response.content
the thing now is. How do i select the method i want to use from the WS i want to consume?
Btw i am using python 3. Not python 2.
If i adapt that example to my case, i would get something like this
import requests
url = 'https://e-beta.sunat.gob.pe/ol-ti-itcpfegem-beta/billService?wsdl'
# headers = {'content-type': 'text/xml'} if needed
headers = {'content-type': 'application/soap+xml'}
body = """<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:ser="http://service.sunat.gob.pe" xmlns:wsse="http://docs.oasisopen.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
<soapenv:Header>
<wsse:Security>
<wsse:UsernameToken>
<wsse:Username>20100066603MODDATOS</wsse:Username>
<wsse:Password>moddatos</wsse:Password>
</wsse:UsernameToken>
</wsse:Security>
</soapenv:Header>
<soapenv:Body>
<ser:sendBill>
<fileName>20100066603-01-F001-1.zip</fileName>
<contentFile>my-file-encoded-on-base64</contentFile>
</ser:sendBill>
</soapenv:Body>
</soapenv:Envelope>
"""
response = requests.post(url, data=body, headers=headers)
print(response.content)
still tho, how do i select the method i want to use?
(don't know much about SOAP), but I'd take a look at zeep again
I'd be surprised if it can't do what you need
how did you get zeep's xml? with create_message?
sadly i don't seem to find it. So i'm asking every where if someone could help me.
you can't find the generated xml?
No, i used requests on the second example
sadly, no. That's for creating the XML
i already did that
i have an xml created
i want to send it to a SOAP ws
but i want to send it to an specific method inside that ws
by using requests or zeep?
have you tried sending the xml with requests with a POST request like this:
(I'd still probably go back to zeep if this isn't working out)
yeah, that's the same example i wanted to use. But, how do i define the method i want to use from the ws?
guessing, but isn't the method defined somewhere in this url: url="http://wsf.cdyne.com/WeatherWS/Weather.asmx?WSDL"?
maybe Weather.asmx? ?
wait is it? let me see
or if you try something like this:
"For example, suppose the StockServices Web service from the preceding procedure contains a Web service method called GetQuote; the Web service method accepts a stock symbol as a parameter, returning the price as a double-precision floating-point number. Enter the following HTTP-GET request in the browser's address bar to test this method:
http://<servername>/apppath/StockServices.asmx/GetStockQuote?tickerName=MSFT "
so instead of GetStockQuote you'd try sendBill
you said you tried this: https://e-beta.sunat.gob.pe/ol-ti-itcpfegem-beta/billService?wsdl but it didn't work
was there some kind of error in the response?
oh that's only a service
I'd try this then
and if this doesn't work, I'd go back to zeep :D
D:
a friend of mine helped me and said he would do this on zeep
import zeep
from zeep.wsse.username import UsernameToken
import base64
with open("20100066603-01-F001-1.zip", "rb") as f:
bytes = f.read()
encoded = base64.b64encode(bytes)
wsdl = 'https://e-beta.sunat.gob.pe/ol-ti-itcpfegem-beta/billService?wsdl'
client = zeep.Client(wsdl=wsdl, wsse=UsernameToken('20100066603MODDATOS', 'moddatos'))
print(client.service.sendBill('20100066603-01-F001-1.zip', b'encoded'))
But it doesn't return the same error as when sending the same data with SOAPUI
so, it is not working correctly.
but with that, at least i now know how to call an specific method.
what does this print: print(client.service.sendBill('20100066603-01-F001-1.zip', b'encoded')) ?
Just a reminder. That all data i've been using is for testing. It is suppoused to give an error, but it is supposed to give the same error on SOAP Ui as on the IDE i'm using. (which is PyCharm)
that prints this
zeep.exceptions.Fault: El archivo ZIP no contiene comprobantes - Detalle: xxx.xxx.xxx value='ticket: 1529609364082 error: Validation File count error'
just so I understand. you get the correct error on SOAP Ui?
and SOAPUI prints this
<soap-env:Envelope xmlns:soap-env="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
<soap-env:Header/>
<soap-env:Body>
<soap-env:Fault>
<faultcode>soap-env:Client.2335</faultcode>
<faultstring>El documento electrónico ingresado ha sido alterado - Detalle: Incorrect reference digest value</faultstring>
</soap-env:Fault>
</soap-env:Body>
</soap-env:Envelope>
yeah i get the error i was expecting on SOAP UI
but not on PyCharm.
do you also send the zip file via SOAP Ui?
yep
encoded on base64
SOAP UI gives you that option, which is what i also need to do.
where can I see the arguments sendBill requires?
If you need more details, just tell me. I'm can give you as much info as i am able to.
that's on the documentation for that ws
it's like this
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:ser="http://service.sunat.gob.pe" xmlns:wsse="http://docs.oasisopen.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
<soapenv:Header>
<wsse:Security>
<wsse:UsernameToken>
<wsse:Username>20100066603MODDATOS</wsse:Username>
<wsse:Password>moddatos</wsse:Password>
</wsse:UsernameToken>
</wsse:Security>
</soapenv:Header>
<soapenv:Body>
<ser:sendBill>
<fileName>20100066603-01-F001-1.zip</fileName>
<contentFile>my-zip-file-encoded-base64</contentFile>
</ser:sendBill>
</soapenv:Body>
</soapenv:Envelope>
and not like the one you can get by inserting that ws on SOAPUI
according to the documentation
it's on spanish. But the example for using that ws is on page 17
how do you run this code?
the given example on the documentation?
no, yours with zeep
i run it on PyCharm
if you comment out the print line, do you get any errors?
what's in that zip file?
an xml
with test data. Not real
Do you want it? I just adapted it from another example on of the example given on the documentation
is it large?
hmmm about 320 lines of xml code
are there many tickets?
hmmm... what are tickets? 😛
don't really know. I assumed you have them defined in your zip file, because 'ticket' is mentioned in the error
can you add this line after your print:
import sys;sys.exit()
and paste if there are any errors
yeah
still, it's not reading what's inside my zip
yeah, but are there any errors?
no other errors?
nope
i just undertood the problem itslef
the ws is not reading the zip file
or what's inside the zipfile
but that's what's strange, i tecnically am doing the same thing on SOAPUI and it works
is your zip file and your file with the code in the same directory?
oh
can you try:
print(client.service.sendBill('20100066603-01-F001-1.zip', encoded))
insted of:
print(client.service.sendBill('20100066603-01-F001-1.zip', b'encoded'))
(and delete sys stuff)
just to be sure, rename the bytes variable. it's a reserved keyword in python and it shouldn't be used as a name (though, it's not likely it's causing errors in this case)
rename to to something like: zip_bytes or anything you like
I'd try adding this to the code:
from zeep import Client, Settings
settings = Setting(strict=False, xml_huge_tree=True)
client = Client([what_you_have_now], settings=settings)
after that I'm running out of ideas unfortunately
@boreal tree, also make sure you have the username and the password in the correct order (and you've posted the username and the password several times, I'd urge you to change the password at least)
I'm sorry i didn't respond, i was absent. The username and password are test data, is not real, i put random numbers to match an example just like it is on its public documentation.
As i said before, the xml has test data and it's supposed to return an error on the ws. My goal is to have the same error on Pycharm. That's how i will know i could send data correctly.
i am currently trying that.
hope it works, because beyond that... no idea :=)
Thank you so much for your help @native tide I know you must be tired of helping me but sadly it did not fixed the problem.
On the other hand. I wonder if print is the best way to get the response form the ws. Maybe the problem is the way i want to retrieve the data?
it's not a problem :)
i get the same error message.
zeep.exceptions.Fault: El archivo ZIP no contiene comprobantes - Detalle: xxx.xxx.xxx value='ticket: 1529616712333 error: Validation File count error'
which is a response the ws is giving me
I think this is the same error as before, right?
in SOAP Ui, do you have everything on one screen?
yep
can you screenshot it and show me?
you mean this?
the value on content file is not what i sent
i wrote that so it could be understandable
lol
the value of content value is base64 encoded gibberish?
what i actualy do is, right click on that field, then "insert data as base64" then select the .zip i need to sent
ok
you can try it yourself if you have soapui
do you want the .zip?
its an xml adapted from an example on the ws documentation
with fictional data
that's why it returns an error, but it returns an error of "invalid value"
i expect to have the same error on PyCharm
but can't have it
:/
can you paste the faultstring on the right?
yeah, because the error you are seeing in pycharm is not the response
<soap-env:Envelope xmlns:soap-env="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
<soap-env:Header/>
<soap-env:Body>
<soap-env:Fault>
<faultcode>soap-env:Client.2335</faultcode>
<faultstring>El documento electrónico ingresado ha sido alterado - Detalle: Incorrect reference digest value</faultstring>
</soap-env:Fault>
</soap-env:Body>
</soap-env:Envelope>
can you also show me what are xmlns:ser and xmlns:wsse in full (on the left)
you can copy just the one line
have to go now
gl
if you figure it out, let me know :)
thanks @native tide
You mean the Soap request xml? if so. It's this one
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:ser="http://service.sunat.gob.pe" xmlns:wsse="http://docs.oasisopen.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
<soapenv:Header>
<wsse:Security>
<wsse:UsernameToken>
<wsse:Username>20100066603MODDATOS</wsse:Username>
<wsse:Password>moddatos</wsse:Password>
</wsse:UsernameToken>
</wsse:Security>
</soapenv:Header>
<soapenv:Body>
<ser:sendBill>
<fileName>20100066603-01-F001-1.zip</fileName>
<contentFile>my-zip-file-encoded-base64</contentFile>
</ser:sendBill>
</soapenv:Body>
</soapenv:Envelope>
now I'm analyzing both base 64 array bit. to see if maybe both are different.
the one generated with SOAPui and the other generated by script
i'm using the following code in order to get the base64 code i'm sending to that ws
from zeep import Client, Settings
from zeep.wsse.username import UsernameToken
import base64
with open("20100066603-01-F001-1.zip", "rb") as f:
bytes = f.read()
encoded = base64.b64encode(bytes)
settings = Settings(strict=False, xml_huge_tree=True)
wsdl = 'https://e-beta.sunat.gob.pe/ol-ti-itcpfegem-beta/billService?wsdl'
client = Client(wsdl=wsdl, wsse=UsernameToken('20100066603MODDATOS', 'moddatos'), settings=settings)
# print(client.service.sendBill('20100066603-01-F001-1.zip', b'encoded'))
# print(client.service.sendBill('20100066603-01-F001-1.zip', encoded))
print(encoded)
it prints this
b'UEsDBBQAAAAAAJB71UykoJUx5j4AAOY+AAAZAA...AEcAAAAdPwAAAAA='
while SoapUIs converter just returns this after generating the base64 code
UEsDBBQAAAAAAJB71UykoJUx5j4AAOY+AAAZAA...AEcAAAAdPwAAAAA=
Isn't the b' affecting the base64 code in any way?
yeah i checked. Both codes are literrally the same
except for the b' at the begining and the ' at the end
b'' indicates that its bytes
just do print(encoded.decode()) # which looks kind of nonsensical, but what's being "decoded" here is ASCII
I've actually always been kind of annoyed by the fact that b64encode returns bytes instead of a string
its .decode()
oops 😛
ohh i see
now it returns the same as on soapUI
i'll try and see if that works
sigh*
it indeed want a byte-like type 😦
So, my concusion is that, the problem is not the encoding of my .zip on base 64. I'll be back on the previous error for now and keep on looking for solutions.
Ok,I found out 1 guy had the same problem. But he says he resolved it cuz the encoding of the zip was actually just econding the xml inside the .zip .Would this be the case for my problem as well? Does the encode method from base64 bypass the .zip and just encode the .XML? Does anyone know something about it?
if so, then why was the base64 code generated on SoapUI the same base64 code i got, generated on Python?
you can try it out
just unzip the file and encode it
I don't think it bypassess the zip
Lemme ask you guys something @brave mantle and @deep cave You guys are the only prof python devs I know
And you roughly know what I can and can't write
And I thought I was in off topic god damn it
I was gonna ask if I'd have any chance at a python webdev job with my current skills
get better at working with others, and focus on readability. you probably have the skills to solve python webdev problems but you lack essential teamwork and readability skills.
being able to solve the problems is really the easy part.
I mean I just am memimg around when I write code but I think I can write readable code
I mean at least I think so
probably. it's not rocket science
just following best practice and style rules.
but do more collab. with flake8.
and uh
Hmm, I'm gonna actually try to finish a full project and put it on github and apply to a couple entry level jobs
another tip
python webdev is often full stack-y
get over your fear of linux.
work with databases
master git
Yeah I can handle basic javascript and html and I am okay as long as there is an ORM for the database
don't expect an ORM
Git, I'm still learning
learn sql
sorry. mobile.
linux isn't scary
dw :3
for web work, it's often less scary than everything else
There are just so many of them
get a vps or something with like centos or ubuntu server and put up shit on it
Oh so just ubuntu is okay, nice :D
get a vps or something
Imma try AWS
I'm just too scared
xD
fuck aws
lol why
so, in theory, by doing this, i am encoding my .xml instead of my .zip, which i can confirm that happening since the base64 code is different from before. But i still get the same error. @native tide
from zeep import Client, Settings
from zeep.wsse.username import UsernameToken
import base64
with open("20100066603-01-F001-1.xml", "rb") as f:
bytes = f.read()
encoded = base64.b64encode(bytes)
settings = Settings(strict=False, xml_huge_tree=True)
wsdl = 'https://e-beta.sunat.gob.pe/ol-ti-itcpfegem-beta/billService?wsdl'
client = Client(wsdl=wsdl, wsse=UsernameToken('20100066603MODDATOS', 'moddatos'), settings=settings)
# print(client.service.sendBill('20100066603-01-F001-1.zip', b'encoded'))
print(client.service.sendBill('20100066603-01-F001-1.zip', encoded))
# print(encoded.decode())
zeep.exceptions.Fault: El archivo ZIP no contiene comprobantes - Detalle: xxx.xxx.xxx value='ticket: 1529696554236 error: Validation File count error'
Oh
digitalocean or scaleway would be much better.
Hmm, welp I'll try to do it that way then I mean aren't the commands and stuff the same
Since it is the same linux distro
Yeah that's not a problem
But aren't they the same as long as they use the same linux distro inside
Like don't they work like I have a remote computer and put my os in it and do whatever I want
and the internal workings
but just like with programming languages - learn one and the rest are easy
Nice
Welp I still have to finish a project to show at applications to prove that I actually learn stuff but I'm definitely gonna try my chances :3
yeah, you should bring a github with something on it
it's a huge advantage over those who do not.
and you know, once you start fucking with a VPS you can suddenly pick up 20 of those buzzwords in a year
I am already probably gonna ask a ton of stuff when I am actually gonna deploy my very first website
I only ever used py manage.py runserver
lol
soon you'll be able to say you know about nginx, gunicorn, postgresql and rethinkdb, you know ubuntu server and systemd and you know travis-ci and github or gitlab and ci-runners and you know linters and you know the basics of a bash script and before you know it, you're one of those guys with a list of tech on their resume
so what you want is just a project on github / gitlab that showcases these techs. then when you brag about knowing all this shit in an interview, you can actually back it up with a URL that shows you used them in a project.
even if it's a stupid project
can i say i know LLVm when i have written a hello world in LLVM?
you could, but I don't know if you should :P
k
I mean I had a working website already but I avoided putting it on github
And am rewriting it
With proper tools
I make it a point to only mention tech that I've worked with for long enough to not feel intimidated by.
like, I have C++ experience too but it scares the shit outta me so it's not on my list :P
@deep cave, thanks, I learned something new about what to put in my CV :=)
Welp thank you lemon, I'm gonna apply to some stuff and as soon as I get a job I'm gonna treat you a döner :3
sounds good
actually, techs I'm not intimidated by has become my main section :D
@boreal tree, can you try:
print(client.service.sendBill('20100066603', encoded))
I've no idea why the error would be about ZIP when you're not sending a zip file
the thing is the ws expects the name of the zip and then the zip encoded on base64.
*If i give it the .xml encoded i get the same error as when i send the .zip
*If I send an incorrect .zip name it returns an error saying the name of the zip is incorrect
*If i send the zip encoded with its name written wrong. it returns an error saying the name of the zip is incorrect
The ws, IS recieving my request, but it's failing who knows why. so up until now i have 2 theories
- The ws is poorly programmed and it just doesn't work properly most of the time.
- The ws has some kind of security that doesn't allow requests from unknown senders. So SoapUI is trusty but doing your own code on an IDE just isn't
ok, so at least there's another error when you send the wrong name
yeah, that's why i know the ws is at least recieving my data
yeah
so... i'm pretty much f*cked right? xd
The sad part about this is that. I've read on forums that the ws provider doesn't actually respond for this errors. If i try to contact them, they will probably ask me to reboot my modem. That's what people said the ws provider told them.
tickets could be how they track errors
yeah the ticket number vary
1529697587691
1529698118169
1529698145386
is what i got from 3 consecutive requests
yeah, that's probaly how they track them
am
is there documentation for the service
?
well i'm planning on doing a documentation on how i got till this point.
it's possible you could find the anwser there
yeah, there is documentation for the ws
it's in spanish?
sorry, can't help you with that :)
first, I'd look specifically for the spendBill method and see what you can find out from that
then I'd go look for filetypes and if there are any errors associated with them
feel free to take a look at the diagram on page 16.
It's public after all.
http://contenido.app.sunat.gob.pe/insc/ComprobantesDePago+Electronicos/manual-programador-setiembre-2016.pdf
no hablo espanol, unfortunately :)
maybe there are some details in the documentation that might give you a clue what could be wrong
I hope.
I'm reading it again
also are you 100% that the error from SOAP Ui is the 'correct' one?
yeah. I'm sure about that one.
Since it's analyzing the xml and telling me the field I put wrong data, has wrong data.
:P
before that I had other kind of error from other wrong data I put there. As I said before all data on that xml is fictional. For now I just gotta make sure i send my data through my custom code on python.
and the error from your program complains about the whole file?
nvm tried to send another xml inside the zip to see if it still gave me the same error (hoping for it to not) But it did give me the same error. So i got nothing.
¯_(ツ)_/¯
which OS are you using?
i'll still try it tho. ty @native tide ~
If i get to make this to work. I'll do a documentation, but if I don't... i'll still probably do it. lolz
like this?
from zeep import Client, Settings
from zeep.wsse.username import UsernameToken
import base64
with open("20100066603-01-F001-1.zip", "rb") as f:
bytes = f.read()
encoded = base64.b64encode(bytes)
settings = Settings(strict=False, xml_huge_tree=True)
wsdl = 'https://e-beta.sunat.gob.pe/ol-ti-itcpfegem-beta/billService?wsdl'
client = Client(wsdl=wsdl, wsse=UsernameToken('20100066603MODDATOS', 'moddatos'), settings=settings)
node = client.create_message(client.service.sendBill('20100066603-01-F001-1.zip', encoded))
print(node)
nope, same error
?
zeep.exceptions.Fault: El archivo ZIP no contiene comprobantes - Detalle: xxx.xxx.xxx value='ticket: 1529702201943 error: Validation File count error'
i have found a github project from other person for consuming this ws, but it's on c#. I'll check and try it out. Maybe there's something i missed.
like this maybe:
node = client.create_message(client.service, 'sendBill' , fileName='20100066603-01-F001-1.zip', contentFile=encoded)
client.service.sendBill() actually sends whatever you have
so that's no good if you wan't to inspect the created xml before it is sent to the server
your code returns this.
<Element {http://schemas.xmlsoap.org/soap/envelope/}Envelope at 0x20e17b42308>
don't worry, i got to go too rn 😛
hey
which is better flask or django
and is there any good ides for web development that are compatible with either of these frameworks
which is better flask or django ah yes, the "vim vs emacs" of python
flask is usually recommended for smaller projects
its a lot more customizable
and gives you a lot more freedom for doing stuff
lol
django is batteries-included, brings e.g. migrations, tests, and whatnot out of the box
and I absolutely hate html
so "which is better"? neither, they're both amazing frameworks
is there any way to like
any recommendations getting into html and css?
I never understood how it really works, even when I try to learn, creating sites with even a login page seem confusing.
its not that I dont know how
Is there a way I can use a wysiwyg ide?
like bootstrap studio or something?
or would that be pointless?
html really isn't that hard
like so I can make a half decent control panel
I always found actual GUI work easier
cause coordinates make sense
but like bootstrap and all that make absolutely zero sense.
in other words, what would it take to make a login page using firebase
I need to have the user sign in with email and password
and then check firebase's api, and after that store their user ID in a cookie?
all the firebase jazz isn't of interest for the frontend, you do that on the backend, unless i don't understand what firebase is
the frontend just displays it
correct
but the backend is django?
aka python
aka actually logging in?
I just dont get the relationship between django and the actual html and css?
django handles the interactions, but that confuses me... lol
how does it know when the button is pressed or whatever?
I am more of a OpenGL man, so I dont really relate to any of this.
{% if messg %}
<script>
alert('{{ messg }}');
</script>
oh I use javascript to check for relationships in the data?
srry I am kind of an idiot
like @meager anchor would it be possible to use Adobe DreamWeaver for the frontend actual html, and then use django for the backend?
no idea how dreamweaver works, i write my html myself
keep in mind that you'd work with django templates though
there is no support for the django template language, or jinja2 or mako in Dreamweaver.
so it's a terrible choice.
it would be theoretically possible, but not practical
Forget dreamweaver
Forget pretty much anything that writes html for you to be honest
You should just learn html
I hear htmldog is pretty good
i saw some of sentdex django tutorial and there while explaining about {% block content %} {% endblock %} , he said its ginger logic, but i dont really get what is this logic
can somebody explain me what exactly is ginger logic?
^
its just similiar to jinja
@jade rapids when we talk about logic in templates, we are talking about added functionality in templates that you cant achieve with just html
anything that starts with {% and ends with %} is logic
for example
{% if not condition %}
<h1>Some text</h1>
{% endif %}
you will only see the <h1> if the condition variable is false
you can translate this into python
if not condition:
print('some text')
yes
remember, logic must always be closed, like variables
{% block content %}
{% endblock %}
are there variables also in jinja?
there is
but in django, the default isnt jinja
they work the same way
{{ variable }}
but some syntax is different
do i need to learn jinja first for understanding django?
no
okie
you can learn django templates
can u recommend me some good resources for django?
sentdex has a good tutorial, but thats in 1.11
pretty printed makes abit more advanced vids in django
ohkie thanks
Learn Django in this video by following along as I show you how to build a simple hello world app and then a guestbook app that uses the templates, models, a...
he is good
i will see that 
and heres a crash course by traversy https://www.youtube.com/watch?v=D6esTdOLXh4
In this video I will cram as much as I can about the Python Django framework. We will talk about the framework and its advantages and we will setup up an app...
hmm
traversy just reads docs out for you
so i'm debating about going for flask or django as a starting point for web development
django looks more interesting though
Both are great frameworks
^
it depends on what you're trying to build
for most webapps i'd say django
flask for other projects where you'd want to have more controol
I honestly dont know
I just want to create feature rich websites, and perhaps make a small social media website or something just for practise
I'm just interested to get into back-end development
Doesn't really matter, the difference is django has lots of stuff built-in
And Flask doesn't
If you are okay with using the built-in go with django
If you want to use your own stuff, go with flask and choose it
I'm just more concerned if using django will hold me back when it comes to gaining knowledge
Knowledge about what?
web development and python in general
You should already know python in general to dive into a framework
I do lol
I've just learned the basics of the language, and I'm trying to dive into a framework
How basics
Things you would learn from going through a book
I've only done low-level stuff in the past in C, but this is the first time im diving into more abstract languages and trying to develop software
If you already know deque, collections, socket, itertools, and etc
And if you can use them
Those are just literally random libraries I pulled out of my ass by the way
If you know what classes are etc and etc
You are good to go
You can just pick django if you want batteries included and flask if not
There is nothing in there that will teach you python anyway, it is just a whole new world called web dev
using django will hold me back when it comes to gaining knowledge
I mean django offers a ORM for database for instance built-in
But you can just choose not to use it
Django offers a built-in user model that you don't have to use
Django offers an administration page you can opt-out
If you want to learn how to use databases especially for instance you can go with flask to learn how to integrate your project with a database
thanks
Could anyone suggest me some good resources on Django's testing framework?
Setting up a django / uwsgi server running on nginx. I have it (fully) setup, I think, but the web server tells me 502 bad gateway on every request now. any ideas?
not sure which config files / dir structures are relevant to paste
ik it's not strictly Python related just not sure where else to ask. been pounding away at it all day
does your nginx error log say anything?
It did. finally got it working, completely destroyed the setup for like the 4th time, reinstalled, etc followed tutorial again and it works now
hi
im trying to make a sqlalchemy query from within a flask wtform class
from flask_wtf import FlaskForm
from wtforms import SubmitField, SelectField, SelectMultipleField
from wtforms.validators import Optional
from components.models import Course
class ProfileForm(FlaskForm):
grade = SelectField('Grade', choices=[(9, 'Freshman'), (10, 'Sophomore'), (11, 'Junior'), (12, 'Senior')],
validators=[Optional()])
valid_courses = Course.query.all()
courses = SelectMultipleField('Courses', choices=[(course.name, course.id) for course in valid_courses], validators=[Optional()])
submit = SubmitField('Update')
@meager anchor hi
im confused because it seems like theres no issue when i run a query in a custom validator in another component's form
from flask_wtf import FlaskForm
from wtforms import StringField, PasswordField, BooleanField, SubmitField, SelectField, SelectMultipleField
from wtforms.validators import DataRequired, EqualTo, ValidationError
from components.models import Student
class LoginForm(FlaskForm):
username = StringField('Username', validators=[DataRequired()])
password = PasswordField('Password', validators=[DataRequired()])
remember_me = BooleanField('Remember Me')
submit = SubmitField('Sign In')
class RegistrationForm(FlaskForm):
name = StringField('Name', validators=[DataRequired()])
username = StringField('Username', validators=[DataRequired()])
password = PasswordField('Password', validators=[DataRequired()])
password_confirmation = PasswordField('Confirm Password',
validators=[DataRequired(), EqualTo('password')])
grade = SelectField('Grade', choices=[(9, 'Freshman'), (10, 'Sophomore'), (11, 'Junior'), (12, 'Senior')], validators=[DataRequired()])
submit = SubmitField('Register')
def validate_username(self, username):
user = Student.query.filter_by(username=username.data).first()
if user is not None:
raise ValidationError('Please use a different username')
i don't know flask, sorry
culol
i can't really dynamically generate the form it seems
do you think joseph knows
possibly
👍
Does anyone know why, in Django/DRF posting data from rest_framework.test.RequestsClient object results in data getting received as QueryDict without keeping data's nature, i.e.
# in my test
data = {'foo': [1, 2, 3]}
client.post(url, data)
# in my view
print(request.data)
# prints {'foo': ['1', '2', '3']}, as you can see 1, 2, 3 got converted to strings, why?
And finally, how can I enforce data's nature to be kept as original?
Found solution, using the json named argument instead of data, like this:
client.post(url, json=data)
What a good way to get started with django/flask and which should i choose
depends on what you need
Something to tinker with to get familiar with the concepts
Theres no need other than self improvement
Both are great. I don't think there's the right answer here.
official tutorials should get you on your way
What are the key differences between the libs then?
if you aren't under time constraints, that seems like a good idea :)
I got all summer 
also don't pay too much attention to flask being a "micro" framework
it doesn't mean it's not suitable for large projects
but it does take a bit more work
and the default environment supports only one request at once afaik
on flask
aren't Django and Flask both synchronous?
@olive wharf i've started doing this tutorial by miguelgrinberg for flask
I am upto chapter 8 and i love it
watch the video to get a rough idea of what the tutorial entails
I decided to start out with django, but ill bookmark it for future use. However I'll most likely sit through Corey schafers vid series on flask first, mostly because i like his work
oh yeah that guy, i have him subscribed aswell
but reddit seems to love miguel grinberg's tutorial
but its not a video-based tutorial like corey schafers
All about preference ¯_(ツ)_/¯
Ill for sure read it when i get to flask though, so thanks for the link
You too 
i'll be sure to enjoy our very wet winter over here 
anyone know of a good way to do memory profiling for a flask application?
May I ask a question @last blaze ?
She
she?
like I mean my own, about web-dev I have no I dea how grid templates work
hey boys, I'm still using flask and when you render a template and send a variable along with it
return render_template("MyPage.html", MyList = [Bunch of string])
whenever this get's parsed in the js code
var MyArray = {{ title }}
jinja2 automatically escapes the apostrophes
so for example the list [ 'memes', 'dreams'] in python transfered to JS becomes ['memes', 'dreams']
I already tried to add safe in the html file
so when I take the python array it doesn't automatically turn them into those hex codes
var Myarray = {{ title | safe }}
yet I still get these escape codes in my JS array, when I take at look through dev tools
if anyone knows how to solve this please DM me.
I have also tried
import jinja2
MyList = [ Bunch of strings]
render_template("MyPage.html",Mylist = jinja2.escape(MyList)
still doesn't work
@native tide
Nothing special needs to be done. Are you sure that your MyList is truly just a list of strings?
well I think it's a list of strings
[('text', 6.400466379878729), ('rdata',5.6693643070101585), ('data', 2.0677782640502413), ('pdata', 5.873699144062637), ('didat', 0.8050372616935684), ('CPADinfo', 0.12227588125913882), ('rsrc', 6.932746768002647), ('reloc', 5.36807357956736)]
and then on the html page in the javascript part the variable has the ' in it which gets escaped to '
@deep prism
ah okay, it's mostly about the javascript bit then.
yeah but I thought it's most appropriate to post here because there ar e apparently python solutions to this through flask
It's strange that your |safe didn't work, because that should be the solution.
<script>
var ctx = document.getElementById("MyChart").getContext('2d');
var Titles = {{ title }}
var Entropy = {{ entropy }}
var ActualColour = []
var borderFolor = []
function getRandomRgba() {
var num = Math.round(0xffffff * Math.random());
var r = num >> 16;
var g = num >> 8 & 255;
var b = num & 255;
var a = 0.2;
return 'rgba(' + r + ', ' + g + ', ' + b + ',' + a + ')';
}
function getRandomRgbo() {
var num = Math.round(0xffffff * Math.random());
var r = num >> 16;
var g = num >> 8 & 255;
var b = num & 255;
var a = 1;
return 'rgba(' + r + ', ' + g + ', ' + b + ',' + a + ')';
}
var Titles = {{ title|safe }};
var Entropy = {{ entropy|safe }}
for (i = 0; i < Entropy.length; i++) {
ActualColour.push(getRandomRgba())
}
for (i = 0; i < Entropy.length; i++) {
borderFolor.push(getRandomRgbo())
}
var myChart = new Chart(ctx, {
type: 'bar',
data: {
labels: Titles.clone(),
datasets: [{
label: 'Entropy',
data = Entropy.clone() ,
backgroundColor: graphColors ,
borderColor = graphOutlines ,
borderWidth: 1
}]
},
options: {
scales: {
yAxes: [{
ticks: {
beginAtZero: true
}
}]
}
}
});
</script>
it should work here correct
It should, the only difference i have is that i used type=text/javascript
I'll try without
nah, same thing. Just works with safe
don't forget to do Shift+f5
because your page is still cached
I do it everytime just incase
<!doctype html>
<html>
<body>
<script>
safe= [('text', 6.400466379878729), ('rdata', 5.6693643070101585), ('data', 2.0677782640502413), ('pdata', 5.873699144062637), ('didat', 0.8050372616935684), ('CPADinfo', 0.12227588125913882), ('rsrc', 6.932746768002647), ('reloc', 5.36807357956736)];
not_safe = [('text', 6.400466379878729), ('rdata', 5.6693643070101585), ('data', 2.0677782640502413), ('pdata', 5.873699144062637), ('didat', 0.8050372616935684), ('CPADinfo', 0.12227588125913882), ('rsrc', 6.932746768002647), ('reloc', 5.36807357956736)];
</script>
</body>
</html>
maybe it's because my string was a byte object that I decoded
Don't forget in the code you posted you have another var Titles = {{ title }} on top, 2nd line
Sorry I'm confused, I don't see a seond var TItles
that was just example code, my first post this code I posted is all of it
I don't see that first code you posted then..
wait sorry let me clarify
my code is just the one I posted right now the JS
everything else is an example
Well the first 2 variables are not |safe
var ctx = document.getElementById("MyChart").getContext('2d');
var Titles = {{ title }} // <-- this
var Entropy = {{ entropy }} // <-- this
var ActualColour = []
var borderFolor = []
And a couple of lines below that you declare them again with safe
ah yeah I just took that off lemme put it back on, my bad
ey it works
turns out you just cant have a space after the |
which I had previously , Thanks! @deep prism
spaces don't matter there though. It must've been something else.
Another question
sometimes when I upload it works
sometimes when I upload I get doubleslashes behind my dir and it tells me this
here is my PyCode
@app.route('/', methods=['POST'])
def upload_file():
print(request.method)
if request.method == 'POST':
# check if the post request has the file part
if 'filepond' not in request.files:
flash('No file part')
return redirect(request.url)
file = request.files['filepond']
# if user does not select file, browser also
# submit an empty part without filename
if file.filename == '':
flash('No selected file')
print("part2")
return redirect(request.url)
if file:
filename = secure_filename(file.filename)
if not os.path.isdir(os.path.join(app.config['UPLOAD_FOLDER'], filename)) != False:
file.save(os.path.join(app.config['UPLOAD_FOLDER'], filename))
MyDict = {}
MyDict = PyDetect.MethMain(os.path.join(app.config['UPLOAD_FOLDER'],filename),MyDict)
session['FilePath'] = os.path.join(app.config['UPLOAD_FOLDER'],filename)
return redirect('http://localhost:5000/Results')
by the way yes discord formatting sux
app.config['UPLOAD_FOLDER'] = UPLOAD_FOLDER
UPLOAD_FOLDER = 'uploads'
when you say it sometimes works and sometimes it doesn.t is that with different files or the same one always?
depends
it's usually when I pick the same file in a session more than once
@deep prism just tested
it's when you pick after a session
when you pick the same file more that one time a session
a session being a restart of the flask server
where does it fail btw, it's in the file.save right?
yeah
if not os.path.isdir(os.path.join(app.config['UPLOAD_FOLDER'], filename)) != False:
what is this supposed to do?
filename will never be a dir
do you maybe want to check os.path.exists or os.path.isfile instead?
and why the double... or triple negation?
yes
I would simplify that if for now
os.path.exists
so
that's what I'm gonna use
if not os.path.exists(os.path.join(app.config['UPLOAD_FOLDER'], filename)):
there's no need for the != False
yeah I know it's like C syntax, but I doubt my self other wise
Putting it is just confusing
don't
because you put it there initially it probably also failed
because you mixed up your negations
nah I put a print there and it worked
yea, not not-equals is very confusing.
either way, your code works just fine for me.
everytime?
It worked in strange cases then, because you were checking for isdir from the beginning
fix your negations
I know you think it's ok, but writing C code in Python is not really
for anyone else reading your code
it was that one thing, and I know it wasn't good
I just wasnt sure
most of my code is python like
no worries 😃
great 😃
it makes no sense though. that isdir thing is just an if-statement. it doesn't change variables, it shouldn't have any effect on the error you had.
It is an os error tho
this is the line on which it errored
file.save(os.path.join(app.config['UPLOAD_FOLDER'], filename))
well
I think it uses shutil internally
the file.save
and it tried to move/copy a file where one already was
and raised an OSError
it does that for some functions
where does a double backslash come from though.
I don't know
the double slashback is there because he is using it on Windows
yeah
and they used repr()
I know os.path.join will make a double backslash if the filename has a backslash, but why would filename have that
to display the error
pretty sure at least
user@host ~ $ print('a\\test')
a\test
user@host ~ $ print(repr('a\\test'))
'a\\test'
so the exception text was repr(path) that failed
it failed before because shutil (most likely) tried to move/copy/save a file onto an existing file
probably from a /tmp dir
because you checked isdir on an existing path
always causing the save.file to be triggered
the file.save is fine for overwriting files though
unless of course it's in use or something prevents it.
Are you sure about that? This seems to imply differently
do you have the full traceback @native tide ?
it would even make sense to not just allow overwrites if it's part of flask or whatever
because that could be easily exploited
yes I do
can you post it?
not anymore since the problem is resolved
it's not in the console since I restarted the server
I changed permission on my file to overwrite and it gives me PermissionError: [Errno 13] Permission denied: '/tmp/uploads/test.html'
So the OS would probably give a more clearer error than just "invalid argument" if it were in use, or invalid permissions.
Idk why it's just "invalid argument", it has to be because of that backslash stuff
C:\test\test.txt
user@host ~ $ print(repr(my_path))
'C:\\test\\test.txt'
user@host ~ $
again, the double backslashes are part of the repr representation of a string
which is used in the raised exception
the actual string does not have 2 backslashes
they are just escaped so you know that the escape sequence \t isn't meant
What other "arguments" can there be though
ok wait.
this is what happens
only if you actually have a tab-escape sequence \t
will repr show \ without an escaping \\
the argument was that he attempted to save a file where one already was, and something failed.
that actually makes sense
Is it easier to use wget / curl to pull html pages with bash or should I just result to beautiful soup?
and is there a way to just read an html file as a text file or is there encoding/decoding that needs to happen? Not really familiar with file encoding types
so, how do people make a photo a button, like in cards? Such as binding a function to the card being clicked
There’s an onclick event you can add inside image tags or add an event listener directly to the ID
You’d do it on the html side
like in my template?
Yeah. That should work. I don’t know the exact implementation in flask but that’s how it’s done in traditional setups
And the html should work the same
also, how could I set up a sort of 'game' between two people, what systems do people usually use to do something like that?
https://i.imgur.com/XkKyT8A.png
raise TemplateNotFound(template)
jinja2.exceptions.TemplateNotFound: index.html``` ?
why does it give me that error and it doesn't load anything up
i have index.html in the same folder
👌 @wary mantle np m8
how can I display an image in flask given the image path?
You cant Display stuff with flask?
well, how can I put an image into the html
with an <img> tag?
well, yeah, but I'm using the path of the image as my 'src' and it doesn't appear to be working
I could be wrong about what I'm supposed to use
- Are you sure that the image exists?
- Where are you putting this <img> tag
I'm sure it exists as the path is copied from the image itself
and using it in my file directory brings the image
by where I'm putting it what do you mean?
Hmm, could you post the whole <img> tag?
<img src='{0}' filename='img.png' width=100 />
C:/Users/myusername/PycharmProjects/Project/playing cards/jack_of_diamonds.png is formatted
That should work 🤔
you could view source and see if the image tag is coming out okay
like inspect element?
nah I mean just view source and see if the image tag is properly formatted but yeah you could do that with inspect too
opening the image in a new tab return 404
might have found an issue
127.0.0.1 - - [29/Jun/2018 17:17:54] "GET /static/2_of_spades.png HTTP/1.1" 404 -
127.0.0.1 - - [29/Jun/2018 17:17:54] "GET /favicon.ico HTTP/1.1" 404 -
it has to be something with my static directory
https://i.imgur.com/8M0PjQt.png
How can I make the text box right in the centre with the button below.
Like this:
https://i.imgur.com/tO7W0EP.png
You could line break right after the form field before the submit button?
Or put the submit button in its own row/div.
As I'm attempting to run a variable into an app route, I get an error: TypeError: end1() missing 2 required positional arguments: 'score1' and 'score2'
127.0.0.1 - - [30/Jun/2018 21:09:29] "GET /end1?score1=107&score2=121 HTTP/1.1" 500 -
I'm not sure why as I'm passing it through here: python return redirect(url_for('end', score2=p1score, score1=p2score))
Those are keyword arguments, not positional
is correct to return 204 after a post request?
yeah, a confirmation should be good
is someone with a bit of experience with flask currently here?
Ask your question :P
so i've got a problem with this: https://hastebin.com/ululiroquw.py
it outputs this exception in the console: Traceback (most recent call last): File "/usr/lib/python3.6/site-packages/flask/app.py", line 2292, in wsgi_app response = self.full_dispatch_request() File "/usr/lib/python3.6/site-packages/flask/app.py", line 1815, in full_dispatch_request rv = self.handle_user_exception(e) File "/usr/lib/python3.6/site-packages/flask/app.py", line 1718, in handle_user_exception reraise(exc_type, exc_value, tb) File "/usr/lib/python3.6/site-packages/flask/_compat.py", line 35, in reraise raise value File "/usr/lib/python3.6/site-packages/flask/app.py", line 1813, in full_dispatch_request rv = self.dispatch_request() File "/usr/lib/python3.6/site-packages/flask/app.py", line 1799, in dispatch_request return self.view_functions[rule.endpoint](**req.view_args) TypeError: receive_vote() missing 1 required positional argument: 'self'
You will not want to use flask for this
Right off the bat
You're implementing the webserver in the same program as your bot
Yeah no, that won't work, because you need something that supports asyncio
You should be using aiohttp
can i receive webhooks with aiohttp?
Yeah, it does the usual stuff
okay, gonna look into that, thank you
You should consider whether this is really what you want though
Most of the time, the site and bot parts are separate apps
i don't want to host a site
i know, but that's not my main purpose
the only thing this code should do is listen for incoming webhooks from Discord Bot List
and process them
Right, but either way, you need an http server
Hey guys can anyone explain me why selenium .page_source does not return the entire page source of a website when its using javascript? E.g. view-source:https://www.reddit.com/user/Hdalby33 in Selenium returns a different page source compared to using driver.page_source
@finite bison your question is strange
oh
view-source: probably returns the unmodified DOM
whereas page_source returns the current DOM, modified by JavaScript
Ah okay, is there a way to view the unmodified DOM through a selenium command?
hmm, im making a register/login system with python, pyodbc and flask, how should i implement a "Confirm your email" functionality
hey.. so i want a button saying advanced, when the user clicks that, something appears. how can i do this with bootstrap ?
@media only screen and (max-zoom: 80%){
.label {
flex-direction: column
}
}
What is the correct way to write this?
I want it to go to a colum past a certain screen zoom
How can I remove or move an image in flask, I want to have it where upon clicking an image, it will remove it
Removing it from ...
an html template
to have it not appear on the page
<img src="{{url_for('static', filename=image_name)}}", width="50", onclick="removeimages()" />
like this
and have the function remove that image
I'm not sure if I have it right though
hmm i have not done any frontend development before, but i do know javacript ,php, and html (css is my weakest skill) and i have almost no skills in mkaing things look nice and i need to make a responsive website, i'd sort of wanna do it with python.
i have made a api for the site with python and flask.
how should i proceed for the front end? django?
aand i have deadline in 4 weeks 😐
no reason you can't continue using flask
if you've already got experience with it, it's probably not a bad choice
html and css will still be required to make it look nice no matter which framework you choose.
but you could use something like bootstrap or bulma to do the heavy lifting css for you
bulma is really nice.
with bulma, flask and some html you'd have a website looking pretty good in mere days.
as for responsive, that'll probably require either css or javascript to pull off - it's not gonna be possible to do with just python
but you said you knew js so that sounds like it won't be a problem.
@wary mantle You can do this pretty easily with some javascript. Stackoverflow has a lot of good examples. Might not all be for bootstrap, but you can probably hack your way through their answers to just add a simple BS button.
@keen ore Python has nothing to do with responsiveness, it is just used for backend
@gentle sapphire I made sure I broke the reverse proxy already by trying new stuff configuring it
For some reason my venv was Python2 instead of Python3 so I attempted to change it
for flask templates, where is the defult ./
i.e. i want ./script.js, where would flask find it
found out, it has to be in a static folder and to load it you have to use <script src="{{ url_for('static', filename='js/script.js') }}"></script>
who tf greenlighted this
Your filesystem would look like this @idle osprey /root/static/js/script.js/
Root being the root dir
Where your index is and your wsgi and app are located
Fixed
Is there anything like a listbox from tkinter in html?
no. but you could build a table and make each row clickable and you'd get close.
then add some buttons
might need a js event handler to make the table rows clickable though. but it's not hard to google a solution for.
(tags like <tr> don't like being wrapped in <a>s.)
I just wanted something that I could add to based on a list
are you using a python web framework?
in that case you can still build that
you just spit out that list when you render your template and then have a for loop in the table that makes a table row for each list item
Does anyone mind if I pm them some questions regarding Django? I am googling most of them, however, I am not sure what a lot of the terms are.
bot.tags.get no-dm
Can I send you a private message?
No. We do not provide one-on-one tutoring - you can hire someone locally if you really need that. We also prefer that questions are answered in a public channel as it means that everyone else present is able to learn from them. If you're working with code that you are unable to disclose for any reason, you should try to make your question more general and write a separate, small piece of code to illustrate your problem.
@cosmic dove ask your question
Speaking of Django when running uwsgi how do I deploy the full project. Like what file do I point it at?
point it at yourproject.wsgi
hmmhow do i post a data from a form to flask without leaving the page and how do i display a text on that page depending in the response from my backend
Ajax @keen ore
Well, i mean sure, but should i return data to it from flask?
also, what about flask-wtf?
No clue what that is but usually you use Ajax to query some endpoint on your flask app to get data you need and display it
@native tide what does the .wsgi consist of?
it's a run file,
it runs the web app
so, mostly an import to call the app, and a main()
can i make a form with "add field" functionality with flask_wtf? i want to have a form where users can add ass many skills as they want in a single go,sort of like this:
Skill name:[ ]
Skill level: [ ]
add skill...
[Submit]
and clicking add skill makes it like this
Skill name:[ ]
Skill level:[ ]
Skill name:[ ]
Skill level:[ ]
add skill...
[Submit]
so can someone explain how onclick works?
Does it have any connection with python?
I want to be able to call a function upon clicking an image, correct me if I'm wrong but I think thats the main solution I should use
by that what do you mean?
This is a python server.
within html
Like this:
<button onclick="js action here">button</button>```
Example with button.
Same with img but you set the source.
so why is it a js action?
You can't run Python in HTML @sour heath
@native tide This channel can be used for talking about HTML, CSS or JavaScript
okay, thanks
Oh, ok. I wasn't sure.
JavaScript is used for scripting webpages, so a HTML element event will always trigger a JavaScript function
No problem
and you can write the js within the html?
you can
So
example time ✨
<script>
function myFunction() {
alert("You clicked the button!")
}
</script>
<button onclick="myFunction()">Click me!</button>
so within the js, you can call python functions, which is the whole tie between them?
oh
Python is nothing to do with frontend web development
oh
There are various ways you can write "Python" in the browser, but I don't recommend any of them
so trying to write a web program with python involved seems useless?
Yes
because you can't do it
you will either write python which gets converted into JS, or just end up using JS
well, good to know
If you are looking to learn web dev, it is one of the things codecademy offers a relatively good course on, so I recommend that
Python is a good skill for backend web dev
You may not be able to write the bit the user sees in Python, but you can certainly write the bit which sends the data to the user and processes requests in Python
well, I don't think I could do it, I'll just have to convert to some gui
If you are looking into GUI's, I recommend looking at PySide2
okay, thanks
wait, were you suggesting I use flask?
because thats like, exactly what I've been using
I was saying python can be used on backend not front end
if you are already doing that then that is awesome :D
I'm really confused as to what you are asking about now
Flask is not a GUI framework
yes, I know that
buttons would be similar yes
great, so using get and post?
You could tie it in using something like requests, yes
using onclick?
Not exactly onclick, because it is not HTML
oh
is this the gui again?
and then we connect the button to a say_hello function
Yes, this is pyside2
In fact
let's move to #user-interfaces
how do i make a existing form on website work properly with flask-wtf form?
we're gonna need more information than that
nevermind, i figured it out 😃
but, now i need to figure out how i can make my page fill the screen and not leave a white void under footer on empty pages
how can i makee the footer stick to the bottom of the page even when there is no content above it
with position: fixed it stays at bottom of the screen and covers any content
anyone ideas why my css works in ie but not chrome?
yeah, tried that, no luck
can you post your css?
#container {
background-color: #ff6600;
}
p {
color: white;
}
pretty simple stuff lmao
what part is not working?
html?
<!DOCTYPE html>
<html>
<head>
<title>Home Page</title>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.1/css/bootstrap.min.css" integrity="sha384-WskhaSGFgHYWDcbwN70/dfYBj47jz9qbsMId/iRN3ewGhXQFZCSftd1LZCfmhktB" crossorigin="anonymous">
<link rel="stylesheet" type="text/css" href="{{ url_for('static', filename='homepagestyle.css') }}">
</head>
<body>
<div class="container" id="wrapper">
<p id="loginforminfo"> Login to continue to the site: </p>
</div>
</body>
</html>
hmm
<p class="infobox">
and
.infobox{
background-color: #ff6600;
}
or replace #container with .container
no luck 😭
hmm
tried changing the href to a static one, didn't work
.container {
background-color: #ff6600 !important;
}
p {
color: white;
}