« first day (3412 days earlier)      last day (1522 days later) » 

4:14 AM
Good Morning All
Good Morning All
 
Good Morning all
 
4:32 AM
Good morning all!
I'm new in the stackoverflow chats so I don't know if this is right or not (sorry if it isn't) can someone check this: stackoverflow.com/questions/60273009/… ?
 
4:50 AM
@VicenteC You shouldn't link questions less than 48 hours old, as per the room rules, please skim them.
 
Thank you, I didn't check the rules
 
5:27 AM
can anyone help with GCP docker?
 
 
1 hour later…
6:32 AM
Greetings my lords
@ParitoshSingh you were about to change the job, did you do it?
 
@Alper I did! Pretty surprised you remembered something like that :P
 
@ParitoshSingh you were talking about moving to tesla or something?
My memory is good as long as I dont drink
@ParitoshSingh details is not important btw, you were talking about something like tesla, I just curious :D
 
Nah, wasn't tesla. I am pretty sure i never mentioned where I'm switching to. I generally tend not to. But yeah, very impressive.
 
6:47 AM
@ParitoshSingh It might be safer to not to mention about it on the internet but yeah, congrats dude
 
Thank you :)
 
cbg guys o/
Congrats @ParitoshSingh boi
 
cbg \o/
 
haha, thanks!
 
Which project architecture level design pattern, you guys use in Python? Like in Android MVVM is preferable..
 
6:57 AM
 
@Alper Interesting, but that can't be project level right? I mean only for some usecases?
 
I might pass some code samples to clients and I should not pass source code so this method helps me pass them an interface without revealing the source code
Working in the automotive industry, secrecy is important, the domain is important :D
I am using factory method pattern in general cases
 
7:17 AM
@Alper ..wait! You're working for an Automotive industry?
me too.
 
7:32 AM
Hey everybody. I wanted to ask a question but the scope was really small and the topic seems like a bit broad. It's about Django Rest Framework. Exception section shows how DRF handles exceptions. I've implemented my own custom exception with default_code. I expect it to respond a code key in JSON yet this does not seem to be the case. It only responds with detail.
The docs are not quite explicit about what default_code does in custom APIException. If it does not add code to responding JSON, what does it really do? Does it inject itself into the custom exception instance?
 
Is win32com library specific to Windows OS?
 
yes, the "win32" part kind of gives it away
 
I use Ubuntu, needed to implement MAPI (Microsoft's Messaging) for Email Services. All that I find is that it is done using win32com :(
Any way for it?
 
7:57 AM
@TheLittleNaruto Yes dude, I am.
@TheLittleNaruto I dont want to ask personal questions :D
 
8:23 AM
morning cbg
 
cbg guys, a quick question, if I have multiple forms that will be saved on different models, do I need to save each form to the database and redirect the user to the next form or I can save all the form at once when the user clicked the submit button? Thanks
 
@superv What technology/platform is that? It is probably available
 
@Alper I am working with Django.
 
Are you using plain forms in the front-end or sending them via ajax? Are you using plain Django forms on the back-end or do you have DRF serializers with nested serializers etc...?
 
8:36 AM
@Alper Yeah But I did. ;-)
 
cbg-ning
 
@TheLittleNaruto It is okay for me
 
@AndyK covering your bases I see :)
 
@Alper I have read that link earlier but doesn't look like what I am looking for. I guess I have to read it again. Thanks
 
@superv Nope, I just passed a sample with a rush
 
8:40 AM
@JonClements not sure to understand, Jon ...?
 
timezones...
 
It might not be the thing that you have been looking for
 
@JonClements ha ha indeed
got to start to make a move. catch u a bit
 
rbrb for now!
 
@Alper Do you work in infotainment too?
It could be Android or Linux.
 
8:48 AM
@TheLittleNaruto Is that a company?
 
No but a domain in Automotive industry.
 
@TheLittleNaruto Nope, I am working on ECU
 
Basically the infotainment unit you see at the center of any car
@Alper Nice
 
@TheLittleNaruto Working on the tools that support ECU development process
Sounds cool, it is not bad at all too
But it is a very old technology so it is boring time to time
 
Certainly, It is.
However I got chance to do Python development for an internal project and that's waht keeping me motivated.
 
8:54 AM
that and getting to hang out with all the cool people here, right? :p
 
Right! 😃
 
9:19 AM
hi all i am using flasgger==0.9.3 in my python flask project
How can I find out whether it is following OpenAPI version 2.0 or 3.0?
It is used like this:
app.config['SWAGGER'] = {
        "swagger_version": "2.0",
        "title": "My flask project"
    }
So does this mean it is OpenAPI 2.0?
 
I'd have thought it just means the swagger version... I'm curious how the heck flasgger is meant to be pronounced though... :)
 
9:39 AM
@JonClements "fl" + "as" + "grrrr...."
 
9:51 AM
@variable Check this release note: flasgger 0.8.2
 
@TheLittleNaruto do you mean this part "Validate examples according to Swagger spec"
It doesnt say about OpenAPI version
 
Fall back to simpler validation for OpenAPI 3
 
Oh "Fall back to simpler validation for OpenAPI 3"
So it is by default 3.
 
Correct example's declaration as OpenAPI 3.0
Yes
btw good finding @variable I'll see if I can use same in my project too.
 
10:08 AM
@TheLittleNaruto but did you see my code above, does it force flassger to use OpenAPI 2.0? or would it still use 3.0?
My output shows "swagger": "2.0" in the swagger json
There is a differnece between Swagger UI version and OpenAPI version
I think swagger_version means the UI version
 
@variable Yeah that's what is written, isn't it?
 
10:24 AM
@TheLittleNaruto I hope I have that kind of thing, it is pretty much boring right now, company sold to another company and everything messy
 
I didn't find this key "swagger_version" mentioned anywhere. @variable
@Alper Thanks to my Manager. :)
 
@JonClements we don't have many cool people left here, everyone take off to Europa for a bigger career and a bigger salary
 
You're most trustworthy
 
Wow... wasn't aware we'd colonised a moon of Jupiter! You'd have thought that'd of been on the news! :)
 
colonised a moon of Jupiter? *thinking*
 
10:28 AM
Being a little mischievous re: Alper's typo...
 
Meanwhile at third world country We were trying to colonized to our country and trying to create a living.
@JonClements Even Grammarly can not stop my typos
 
was tehre in an older version. do you think it is irrelevant in latest versions?
 
10:43 AM
@variable I think it's configurable; check this line of code: github.com/flasgger/flasgger/blob/…
openapi_version = self.config.get('openapi')
if openapi_version:
    data["openapi"] = openapi_version
else:
    data["swagger"] = self.config.get('swagger') or self.config.get(
        'swagger_version', "2.0"
    )
 
Doesnt say what the deafult openapi version is or how to configure it
 
@variable When you initialize the Swagger class in your project, that time you can pass the openapi version
 
I did try this
but doesnt make any differnece
 
you should ask on the project's issue tracker then
 
@AndrasDeak Well said Andras, but I believe that not everyone on earth has the same morals as we have. I believe in honor but not everyone. People tend to get approvals from outsiders those people who can not find in themselves yet.
 
11:30 AM
@Alper yes, morals are a society-dependent and even subjective thing. I'm implicitly assuming the ethos of Western democracies wherein we all are equals. Which happens to be the same notion that governs Stack Overflow, a company founded by liberals from the US aimed at programmers (who tend to be very democratic in my experience)
 
@AndrasDeak I can not agree with you more. People always use shortcuts to get the places where they want instead of where they deserve. Sad but true :D
 
11:51 AM
Best python ide?
 
closed as opinion based :P Personally i use spyder, and notebooks if i must. lately i've been pleasantly surprised by vs code, giving it a whirl.
 
we should write a wiki about that because this comes up every other day now
maybe put it in the room topic
 
@Andras don't we already have one (of some sorts anyway?)
 
I am bored from Pycharm
 
About IDEs? No idea, I just remember the tutorials.
@Alper being bored by it is the best possible scenario for an IDE
@JonClements oh, neat! I'll just dupe people's questions there, thanks
I should add "not actually an IDE" to the vim cons
 
@AndrasDeak So, I should be bored lmao. It actually make sense
 
Looks like it's missing a few that are quite popular among people but I think those are the most common
@AndrasDeak s'pose it's debatable whether ST is an IDE...
although with plugins and sublime merge alongside...
 
I am pretty lazy to configure PyCharm every time I run something
 
fortunately when people ask for IDEs they often just mean editors
we should also add "IDLE: no, don't even think about using this"
 
11:59 AM
Why does the vim website so ugly? I think I get used to commercial websites a lot
 
@AndrasDeak Is it really that bad? I only know about it from people asking strange questions on SO main.
 
me too but that's enough :P
 
Hmm, deciding to follow up on a freeCodeCamp tutorial to their main page has just opened a big bag of worms. I've come to accept that no further work will be done this week; the dilemma is where to start tackling that list...
 
Is IDLE even close to an IDE though? Sure it's got a bit of GUI around an interpreter... but if you're going to call that an IDE then ipython more than qualifies
 
in my opinion the line for "IDE" lies between ipython and jupyter-notebook, because in the latter you can see and edit all your code
 
12:05 PM
Fresh cabbages everyone
 
in ipython you only edit one cell at a time
 
urgh, don't go around recommending notebooks as IDEs.
Had to salvage that more than once.
 
talking about technicality
Technically I'd accept notebooks as IDEs. I wouldn't recommend putting them in a salad them as IDEs.
 
Yeah... I quite like jupyter notebooks... especially doing stuff with pandas and matplotlib etc... used it a few times with markdown cells and images and html tables and hide the code cells then export as pdf etc...
 
Being able to work on actual, raw source code is kind of a baseline requirement on IDEs for me. notebooks aren't suitable for that, hence some of my frustration having to pull out other people's code.
 
12:11 PM
@MisterMiyagi I used to use it as my 'IDE' when I started out. I just use it for the REPL now. Pros: f5 (runs code) and it syntax highlights, Cons: everything else
 
How does it compare to ipython? Didn't look for other REPLs since finding it.
 
I've never used it
 
Ah. In that case, I can heartily recommend it. ;)
 
I like that ipython binds your hand so you can't end up in stale state (unlike notebooks)
of course there's less "state" to speak of
 
magic commands and history recall and being able to do a cheating - "oh boy - I forgot something - let's just do "!pip install openpyxl"' kind of thing
 
1:05 PM
Cabbage all
 
1:18 PM
back
 
1:46 PM
If we have a dupe target for "how do I decrement the value in my for i in range(...): loop and make that value stick until the next iteration?", then stackoverflow.com/questions/60282271/for-loop-return-value needs it
 
yield is pretty sick topic
 
yield is cool, and strong, and it is my friend
 
That's certainly an interesting answer to it... /me looks puzzled
 
The answer gets insta-down-voted lmao
 
 
1:50 PM
You can send random episode of the nerd cartoon guy, I dont remember his name
 
... Dilbert?
 
@Kevin Exactly
 
Also, I have no idea waht I am looking at: stackoverflow.com/questions/60282401/…
 
 
I stopped reading Dilbert once I identified more strongly with Wally than any other character
 
1:54 PM
You must embrace yourself. Real self
 
Hey guys a quick question. I want to apply a filter and I cannot access a column. However, I do not think it is a column, I converted from dictionary to dataframe. Here is what I have
                          direction      Long       Lat
id1                       south          42         4
id2                       north          32         5
id3                       north          22         6
Index(['direction', 'Long', 'Lat'], dtype='object')
 
which python version were f-strings (format strings) introduced?
 
how do I refer to the ids
 
@paul23 3.6
@Vasilis MCVE please
 
With loc?
 
1:58 PM
Hmm I guess I need to downgrade my own version to 3.5 so it aligns with the server XD.
 
>>> df = pd.DataFrame({'direction':['south', 'north', 'north']})
>>> df.index = ['id1', 'id2', 'id3']
>>> df
    direction
id1     south
id2     north
id3     north
>>> df.loc['id1', :]
direction    south
Name: id1, dtype: object
 
Is there an easy way to install a virtual environment with a different python version - one that isn't install globally?
 
I'm going to guess, with zero evidence, that Anaconda can do that.
 
Well without adding a whole batch of extra libraries and ides :P
 
@paul23 Do you have it installed? Cause you can use the --python. If not there's a library for that
 
2:04 PM
If your requirement is "without installing anything other than Python", I don't think you can do that. If your requirement is "without installing a lot of other things", I'm surprised to hear that Anaconda requires a lot of other things.
If you want to install a virtual environment, you have to be willing to install something, or else you can't install a virtual environment
 
 c1, c2 = Counter(s), {}
        for k,v in c1.items():
            c2.setdefault(v, []).append(k*v)
 
Uh, well install python directly into the local directory without also potentially messing up global version of python.
 
how does the append work there ^^^ surely it should have been k,v?
 
I doubt it should have been k,v, because append does not take two arguments
 
it works though
 
2:07 PM
anaconda is a bit of a pain since it's not on snap/apt as far as I can see, so it means I have to add another update script etc...
 
@paul23 If you have the the version of python you want downloaded and built on your system you can call it directly when you build the venv I believe like: ` python3.3 -m venv venv`
 
It doesn't work on my machine:
>>> from collections import Counter
>>> s = "hello world"
>>> c1, c2 = Counter(s), {}
>>> for k,v in c1.items():
...     c2.setdefault(v, []).append(k,v)
...
Traceback (most recent call last):
  File "<stdin>", line 2, in <module>
TypeError: append() takes exactly one argument (2 given)
 
yes exactly
 
@Kevin It's k*v not k,v
 
so why does k*v work?
 
2:07 PM
@Peilonrayz I know. I'm disputing Permian's assertion that it should have been k,v.
 
dont worry acutally
 
If you're asking "how does k*v work when k is a string and v is an integer?", you're allowed to multiply strings and integers.
 
@paul23 you can also just use the --python=.... command to create an environment with a particular python version. not sure about the meaning of your update script comment
 
>>> "foobar"*2
'foobarfoobar'
 
2:09 PM
i see now
 
but it may depend on whether you use venv or anaconda
 
Hello everyone, New to StackOverflow chatroom, Can I request to look at my Question in stackoverflow here?
 
@Dodge well when I do python3.5 -m venv venv3.5 it says "python3.5 not found" - and last time I installed python of a lower version globally it changed all python3 commands to use the lower version, screwing me over big time/had to manually hunt those.
 
@Celestial If it's older than 48 hours, then yes. See the room rules.
 
@TobiasTriesch I "just" use python with pycharm, so no anaconda and just venv.
 
2:10 PM
@MisterMiyagi yes please. This is the link : stackoverflow.com/questions/60210426/…
 
@paul23 Don't add it to the path, or edit it's position in the PATH to lower precedence.
 
@MisterMiyagi just to note that in terms of asking us to answer it then that's the case. In the case of asking for how to improve/proof-read it etc... there's no timescale for that kind of thing
 
@paul23 yeah, download it and build it in a folder named appropriately. It won't ruin your system anything if you do that. The system interpreter lives in its own place and is found only when looked for in that place
 
I've obviously missed something... where has this k, v vs k * v thingy come from?
 
@Celestial That links to a comment on a question answered years ago. Are you sure that's the correct link?
 
2:12 PM
Followed by @Permian's assertion that it works, when there is no way that it could
 
@MisterMiyagi It is four days old Topic:Read a file and extract data and assign to a variable from a python file
 
@PaulMcG ahh... thought there must have been something before that... thanks
 
@Celestial I don't see anything obviously wrong in your code (other than the print ("Path is:", ["conan"]["conan"]["CPPPATH"][0]) line, which will never execute, since it appears after an unconditional return statement, and also it's missing the data before ["conan"]). Since the error message is coming from scons, the problem is probably with scons, and we don't know too much about scons here in the Python room.
 
@Celestial eh, my bad. Should drink more coffee...
Either way, the question was answered already, no?
 
@paul23 check this out:
259
A: Use different Python version with virtualenv

The AelfinnSince Python 3, the Python Docs suggest creating the virtual environment with the following command: python3 -m venv <myenvname> Please note that venv does not permit creating virtual environments with other versions of Python. For that, install and use the virtualenv package. Obsolete info...

 
2:17 PM
StackOverflow tip: don't mark an answer as accepted unless it solves your problem
 
Yes, @Celestial, what else are you looking for on this question?
 
apparently venv does not support creation of different python version environments
 
Once an answerer gets their green checkmark points, there's not much incentive for them to continue helping
 
@TobiasTriesch I do this all the time. Create the virtualenvironment with -p option.
 
@PaulMcG Tobias linked to venv, not virtualenv
 
2:18 PM
hmm okay. Then I was wrong
 
Then when you activate it, the "python" command is symlinked to the one you created the virtualenv with.
 
@Celestial It seems you have edited your question to include a follow-up problem triggered by scons. I'd recommend opening a new question for the new problem.
 
@Peilonrayz I beg to differ - have been doing this with virtualenv forever
 
@PaulMcG Yeah you can do it in virtualenv, Tobias linked to venv tho
 
Yes, I see now - never mind, nothing else to see here, move along...
 
2:20 PM
but venv is so simple and it is the one I thought, as a community, we were all supposed to be using. Venv is the official virtual environment thingy, right?
 
@kevin yes I added data before ['conan']...sure will check in scons group, Thanks
@MisterMiyagi np :) that code worked on my standalone program so ticked it right answer. But when I incorporated in my main program it fails with the error I mentioned. Sure will open new question, Thanks
 
well virtualenv still "requires" a link to the python version on the pc, so it still needs to be installed globally (or at least build somewhere on your pc), it can't do something like nvm can for node and directly download python from PyPi.
 
Hello
 
Greetings
 
I have a question and I dont know if this is an appropriate chatroom to discuss abt
// baseFromJavascript will be the javascript base64 string retrieved of some way (async or post submited)
$baseFromJavascript = "data:image/png;base64,BBBFBfj42Pj4"; // $_POST['base64']; //your data in base64 'data:image/png....';
// We need to remove the "data:image/png;base64,"
$base_to_php = explode(',', $baseFromJavascript);
// the 2nd item in the base_to_php array contains the content of the image
$data = base64_decode($base_to_php[1]);
// here you can detect if type is png or jpg if you want
I would like to convert this php code into python
but i do not know how
 
2:35 PM
The problem is 50% Python, so it's on-topic enough... although it's a crapshoot as to whether anyone has enough PHP know-how to give useful advice
 
The equivalent of explode should be split or partition methods of str, e.g. baseFromJavascript.split(',')
 
Now that I read the code, this looks familiar. Didn't I write a little snippet last week that did basically this?
Feb 13 at 17:03, by Kevin
import base64

#typical data, taken from https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/toDataURL#Examples
s = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAADElEQVQImWNgoBMAAABpAAFEI8ARAAAAAElFTkSuQmCC"

data = s.split(",",1)[1].encode()
with open("result.png", "wb") as file:
    file.write(base64.decodebytes(data))
 
as for base64_decode, there is a module in the standard library for base 64 en/decoding
 
My finest work: answering a question five days before it was asked
 
@Kevin I'm actually new to coding, reading this , this is actually decode the base64 image and write the code in binary form and save it as a file?
@Kevin Deja vu!
 
2:38 PM
Basically, yeah
 
please correct me if im wrong~
https://ourcodeworld.com/articles/read/76/how-to-save-a-base64-image-from-javascript-with-php
the code is taken from here ^ , so if i were to put this code inside my python, it reads the data from the html code right?
 
If you put exactly the code I have written in your script, it won't read the data from the html side -- it will simply use the sample data that is assigned to s
Presumably you'd need to replace that line with s = somehow_get_the_data_from_html()
 
how do i do that? because from html side im saving the image in base64, and sending it over to python to decode it
 
@Kevin I've switched over from s.split(",",1) to s.partition(","). Always returns 3 values whether the separator is present or not, so the later code can be cleaner
Also, partition timing is much faster than split
 
I, too, almost always use partition when I only need to split once, and I'm not sure why I didn't here
 
2:44 PM
Hmmmm
 
@VentusZXC Last time I suggested that stackoverflow.com/questions/42762269/… might have a similar setup to what you've got, so something like s = request.values['something goes here???'] would probably do it
 
Alright. Will hv a look. thanks ya
 
Comparing the ajax call in that question to the ajax call in your question, it might actually just be s = request.values
... Although I'm wary of the plural "values" here, since you have only one value: the string
 
Oh, at the moment im not using ajax
im using the tutorial i posted just nw
 
That seems contradictory to me. The second code block in that tutorial has an $.ajax call.
If you use that ajax call exactly, then I expect s = request.values['base64'] will get you the data
 
2:50 PM
Oh
the ajax is actually the alternative of the html code right?
I'm unsure, but just to make sure
 
Ah, I see. "Or if you don't want to use a form, simply use ajax:". I didn't read closely enough to recognize that the second code block is optional.
If you're submitting that data as a form, then stackoverflow.com/questions/42154602/… is probably the way to go. Try s = request.form['base64']
 
so i try with your code yeah?
 
Yeah.
 
alright, let me try
what is image/png and how is it different from image.png ?
 
it's one different
 
2:59 PM
image/png is the MIME type string that identifies what sort of data is being created by HTMLCanvasElement.toDataURL(). We already know it's a png, so we discard it from the string using s.split(",",1)[1]
See developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/… for more information about data URLs than you require
image.png is the name of the file that will be created. It doesn't have to be called image.png. You could call it coconuts.png if you desired.
 
oh
should i use s.split or partition?
 
use partition
it's perfect for such cases
 
partition is slightly faster. In this particular case, it probably doesn't matter, since the internet connection latency will swamp the difference by a factor of a thousand or so.
 
hmm
i tried but since im putting it on my python server
it failed to start
 
If you can get both approaches working, use partition. If you can get the split version working but don't know the right arguments for partition and have been banging your head against the wall for an hour, use split.
 
3:03 PM
it's not also faster than just limiting split to one element - it also offers a guarantee to return a 3-tuple regardess
 
This typically means that you attempted to use functionality that needed
an active HTTP request. Consult the documentation on testing for
information about how to avoid this problem.
I try to use split and see how it goes :D
 
An error message like "you attempted to use functionality that needed an active HTTP request" will probably not be solved by switching from partition to split, or vice versa. Neither of them require an active HTTP request.
s = request.values['base64'] probably does require an active HTTP request.
 
@JonClements That's the main reason why I like it, especially with unpacking. rpartition also works nicely if a prefix is optional.
 
indeed
 
@Kevin hmmm
3
Q: (Still) Getting RuntimeError: Working outside of request context. when trying app.app_context()

Josephfrom flask import Flask, request app = Flask(__name__) @app.route('/post/', methods=['GET', 'POST']) def update_post(): # show the post with the given id, the id is an integer postId = request.args.get('postId') uid = request.args.get('uid') return postId, uid def getpostidandui...

will this solve the problem?
 
3:09 PM
If the question is now "so how do I get an active HTTP request?", I have no idea. I didn't even know it was possible for a Flask process to execute without one.
 
I see...
 
@VentusZXC That guy's problem is basically that he was explicitly calling his function before if __name__ == '__main__':, rather than letting the server mainloop do it. If you're calling your function from the global scope too, then yes, not doing that should solve the problem.
 
oh i want the server mainloop to do it
should i include the code that you provided into this?
@app.route('/', methods=['GET', 'POST'])
def upload_image():
    # Check if a valid image file was uploaded
    if request.method == 'POST':
        # Check if the post request has the "file" part. If no, redirect to upload form.
        if 'file' not in request.files:
	    print("1")
            return redirect(request.url)
        # If 'file' part present, assign uploaded file data to 'file'.
        file = request.files['file']

        # If no file selected, browser submits an empty part without filename. Redirect to upload form.
this is part of the main function that detects if there's a legit image file being uploaded
 
I don't think that code will work. request.files only contains something if your form has a <input type=file> element. You don't have one of those, as far as I can tell.
I don't think you need any of this logic to check whether the request has a file part, etc etc, since you always add the data during the submit event. So you may as well delete all of that, I expect
 
3:22 PM
@Kevin Yeah the code is there because previously i was using input=file approach, now im using webrtc approach which is super problematic hahaha
why cant python just run the server like it should be, so much problems XD T_T
 
Ok, so, recap. What you should be trying is:
@app.route('/', methods=['GET', 'POST'])
def upload_image():
    s = request.values['base64']
    data = s.split(",",1)[1].encode() #todo: try partition instead
    with open("result.png", "wb") as file:
        file.write(base64.decodebytes(data))
 
what is i dont delete the request.files code? it wont cause any errors right?
Okay
 
@VentusZXC Welcome to programming, where "making the computer do what I mean, rather than what I say" is 95% of our job
If you don't delete the request.files code, I would expect it to either 1) crash; or 2) execute the if 'file' not in request.files: conditional, print "1", and redirect you back to the form page.
I'm not sure which, because I don't know what happens to request.files if there aren't any files. Maybe it's not even a valid attribute, or maybe it's a valid attribute but it's an empty dict, or maybe some wacky third option I haven't considered
 
okay
ill give it a try
 
Programming tip: When building your prototype, failure is usually inexpensive. Therefore, try many things, even if you don't think they're likely to succeed.
 
3:32 PM
@AndrasDeak That's a new way to detect planets around stars? The old way was to see the starlight flicker just a bit, right? Problem with that method is that it detects planets that are boiling hot...
 
@VentusZXC have you thought of maybe using the flask version of wtf-forms for stuff?
It's at flask-wtf.readthedocs.io/en/stable and enables you to abstract away/do stuff way more easily then doing what you're doing....
I lose track of how many projects @davidism is working on now, but fairly sure flask, wtf and click and others are all getting his loving and continuous input these days...
 
I'm adding like 5 more to my list because my team at work is in the process of open sourcing a bunch of stuff. You start maintaining one thing and you just can't stop.
send help
 
Wouldn't it be funny if there was some plugin for Flask that seamlessly supports image uploading and made all of the last two hours of troubleshooting completely superfluous
 
@JonClements no i havent thought of that because my programming base is low, im not confident to modify the code. plus im doing a demo project too
T_T
 
@Kevin you mean like WTF with a FileField, or possibly - I can't remember if it's native or something, but sure there's an ImageField etc...
@VentusZXC when doing a demo - generally use all the stuff readily available to do it maybe? Unless you're demoing you can do stuff from scratch without library support kind of thing.
 
3:41 PM
I haven't followed the current conversation, but using JavaScript to post the base64 encoding of an image seems wrong. You can post files in JavaScript without encoding them by using FormData. Flask already supports request.files to parse them out as file-like objects, or WTForms has FileField, and Flask-WTF's FileField integrates with request.files better.
 
Underhanded solution: delete all your code from the image upload page and make it return "file uploaded!" instead. During your demo, make sure the file you're pretending to upload already exists on the server. Don't let anyone try to upload a different file.
@davidism It seems that Ventus did attempt the request.files approach to some extent, but gave up on it for unspecified reasons. My headcanon is that they wanted to upload the contents of an HTML5 canvas, which doesn't exist anywhere in the client's file system, so a file-based solution wouldn't be entirely trivial.
But that's only the polite fiction I invented to retain my sanity -- it may have no bearing on reality
 
I'm sure there's a way to dump a canvas to a FormData field, but I'm not a JavaScript expert.
 
@JonClements yea im using stuffs readily available
@davidism no im not using JavaScript to post base64 . im actually using html to post the base64 code which is saved in <textarea> to the python server which then decode the base64 code into proper image
 
stackoverflow.com/questions/19032406/… lists some canvas-to-file solutions, which look a bit convoluted to me
Half of them need to convert the canvas into base64 anyway, at which point you may as well send that instead of doing the file-based song&dance
The question still remains as to whether the data needs to be stored in a Canvas to begin with
 
Yeah, stop doing whatever you said you're doing, you're making it way more complicated than it needs to be.
 
3:50 PM
Oh T_T, ive been trying to solve this but to no avail T_T
 
If you're asking the user to upload a file, then you write that file to a canvas, then you send that canvas' base64-encoded data to the server via a hidden textbox... There is an easier way.
 
Hmm my current approach is that im using WebRTC which the camera is automatically activated when the page finishes loading. so tht the user can take his face photo, and submit to the server
 
@Kevin this sounds like a fingerprinting method?
 
if user is uploading a file, that wouldn't be a problem, but now the webrtc approach is that the images are saved as dataURL form
 
I don't know what WebRTC is, so I'll take your word for it that the dataURL approach is necessary.
 
3:54 PM
the fact that you're getting it from webrtc has no bearing on being able to send it as form data.
this really sounds like a JavaScript question at this point, the JavaScript room is a better place for that
 
Let's un-digress. Twenty minutes ago you said you'd try the approach I suggested. Have you tried it? Did it work? Did it fail and produce an error message? Where are we at?
"to no avail T_T" implies to me that it didn't work, but more diagnostic information is required
 
my mistake was i did not open the debugging console when the error occurred.... I tried your suggested method
It didn't. No error message came out
 

« first day (3412 days earlier)      last day (1522 days later) »