Statsmodels and crossed random effects
Hi, it is said [here](http://www.statsmodels.org/dev/mixed_linear.html), last sentence of the second paragraph, that statsmodels does not support crossed random effects. Is there a way, in python, to fit a model with a structure such as :
Factor | Def. | Status | Degree of liberty
---|---|----|----
Bloc | Day | Random | 2
A | Preparation | Fixed | 2
Bloc * A | Interaction of Prep and Day | Random | 4
---|---|----|----
B | Temperature | Fixed | 3
A * B | Interaction of | Fixed | 6
Error | Unit | Random | 18
Total | ||35
Here is my data:
day,temp,prep,unit
1,200,1,30
1,200,2,34
1,200,3,29
1,225,1,35
1,225,2,41
1,225,3,26
1,250,1,37
1,250,2,38
1,250,3,33
1,275,1,36
1,275,2,42
1,275,3,36
2,200,1,28
2,200,2,31
2,200,3,31
2,225,1,32
2,225,2,36
2,225,3,30
2,250,1,40
2,250,2,42
2,250,3,32
2,275,1,41
2,275,2,40
2,275,3,40
3,200,1,31
3,200,2,35
3,200,3,32
3,225,1,37
3,225,2,40
3,225,3,35
3,250,1,41
3,250,2,39
3,250,3,39
3,275,1,40
3,275,2,44
3,275,2,45
/r/pystats
https://redd.it/7lko4r
Hi, it is said [here](http://www.statsmodels.org/dev/mixed_linear.html), last sentence of the second paragraph, that statsmodels does not support crossed random effects. Is there a way, in python, to fit a model with a structure such as :
Factor | Def. | Status | Degree of liberty
---|---|----|----
Bloc | Day | Random | 2
A | Preparation | Fixed | 2
Bloc * A | Interaction of Prep and Day | Random | 4
---|---|----|----
B | Temperature | Fixed | 3
A * B | Interaction of | Fixed | 6
Error | Unit | Random | 18
Total | ||35
Here is my data:
day,temp,prep,unit
1,200,1,30
1,200,2,34
1,200,3,29
1,225,1,35
1,225,2,41
1,225,3,26
1,250,1,37
1,250,2,38
1,250,3,33
1,275,1,36
1,275,2,42
1,275,3,36
2,200,1,28
2,200,2,31
2,200,3,31
2,225,1,32
2,225,2,36
2,225,3,30
2,250,1,40
2,250,2,42
2,250,3,32
2,275,1,41
2,275,2,40
2,275,3,40
3,200,1,31
3,200,2,35
3,200,3,32
3,225,1,37
3,225,2,40
3,225,3,35
3,250,1,41
3,250,2,39
3,250,3,39
3,275,1,40
3,275,2,44
3,275,2,45
/r/pystats
https://redd.it/7lko4r
A Redis backed Python Dictionary
https://github.com/richardasaurus/persistent-dict
/r/Python
https://redd.it/7lkdvq
https://github.com/richardasaurus/persistent-dict
/r/Python
https://redd.it/7lkdvq
GitHub
richardasaurus/persistent-dict
persistent-dict - A Python dict which stores data in Redis
Early Access for my book, Make Art with Python, out now!
Hey r/python!
I've spent the past year working on a book to teach the fundamentals of programming through art in Python. It's called [Make Art with Python](https://www.makeartwithpython.com), and it's in early access starting today.
Along the way, I've learned a lot about Pygame, and built a few interesting projects you [may](https://www.makeartwithpython.com/blog/video-synthesizer-in-python/) [have](https://www.makeartwithpython.com/blog/poor-mans-deep-learning-camera/) [seen](https://www.makeartwithpython.com/blog/10-print-in-python/) [here](https://www.makeartwithpython.com/blog/visualizing-sort-algorithms-in-python/).
I wanted to thank Reddit for all the early readers, and to let you all know that you can get the first three chapters of my book now free at my site.
I'm happy to answer any questions about writing a book in Python with Pygame, creative programming, learning to program, or startups in general.
Thanks and Happy Holidays!
- Kirk
/r/Python
https://redd.it/7ljqr6
Hey r/python!
I've spent the past year working on a book to teach the fundamentals of programming through art in Python. It's called [Make Art with Python](https://www.makeartwithpython.com), and it's in early access starting today.
Along the way, I've learned a lot about Pygame, and built a few interesting projects you [may](https://www.makeartwithpython.com/blog/video-synthesizer-in-python/) [have](https://www.makeartwithpython.com/blog/poor-mans-deep-learning-camera/) [seen](https://www.makeartwithpython.com/blog/10-print-in-python/) [here](https://www.makeartwithpython.com/blog/visualizing-sort-algorithms-in-python/).
I wanted to thank Reddit for all the early readers, and to let you all know that you can get the first three chapters of my book now free at my site.
I'm happy to answer any questions about writing a book in Python with Pygame, creative programming, learning to program, or startups in general.
Thanks and Happy Holidays!
- Kirk
/r/Python
https://redd.it/7ljqr6
Make Art with Python
Programming for Creative People
Users click Yes/No link in email as alternative to logging in or submitting form in email? Q about GET/POST Security
I’m building a system for work where we want users to respond periodically if they want paper delivered to their office. Ideally we could send them an email, they would login, and say yes/no and check a box in a form for which day they want delivered. The problem is people complain if we ask them to login. So I’m considering alternatives and would appreciate feedback:
1)I understand that including a <form> in an email is a bad idea (likely to render incorrectly, etc. is this true?)
2)Would it make sense to send an email with two <a> links, a “Yes” and a “No” link. Every two weeks we could generate a unique uuid for that person, send them the email, and then record if they click “Yes” or “No” on this /temporary_user_id/yes_id or /temporary_user_id/no_id page. This isn’t super-sensitive info, so if their email got hacked and someone clicked YES or NO, it wouldn’t be a problem. And once they are on the "Yes" page, we can include a login for them to give dates/times in a <form> if they will.
a.Are there any glaring security holes with having people click YES/NO like this and saving their respond in the database? We’re comfortable having incorrect info for yes or no. I am wondering if this approach opens us up to some kind of injection or XSS attack?
b.I read somewhere that for changing state, it’s better to use POST and not GET see [here](https://code.djangoproject.com/ticket/15619) . Clicking a link in an email is GET. Would it be more secure for them to click on the link and then I redirect them on the backend to submit their “YES” or “NO” as a POST (where I can include a {%csrf_token %}? Can someone explain more how to do this and why this is a security hole? I was reading about this [here](https://code.djangoproject.com/ticket/7989)
c.If I wanted to include day of the week form, should I make them login to do this, or could this also be on the “Yes” page and they submit this <form>without logging in? I figure if every 2 weeks we change the temporary_user_id, this is reasonably secure since no one in the public could find this page (we will use multiple uuids). Am I at risk of some injection attack here?
/r/django
https://redd.it/7ll31b
I’m building a system for work where we want users to respond periodically if they want paper delivered to their office. Ideally we could send them an email, they would login, and say yes/no and check a box in a form for which day they want delivered. The problem is people complain if we ask them to login. So I’m considering alternatives and would appreciate feedback:
1)I understand that including a <form> in an email is a bad idea (likely to render incorrectly, etc. is this true?)
2)Would it make sense to send an email with two <a> links, a “Yes” and a “No” link. Every two weeks we could generate a unique uuid for that person, send them the email, and then record if they click “Yes” or “No” on this /temporary_user_id/yes_id or /temporary_user_id/no_id page. This isn’t super-sensitive info, so if their email got hacked and someone clicked YES or NO, it wouldn’t be a problem. And once they are on the "Yes" page, we can include a login for them to give dates/times in a <form> if they will.
a.Are there any glaring security holes with having people click YES/NO like this and saving their respond in the database? We’re comfortable having incorrect info for yes or no. I am wondering if this approach opens us up to some kind of injection or XSS attack?
b.I read somewhere that for changing state, it’s better to use POST and not GET see [here](https://code.djangoproject.com/ticket/15619) . Clicking a link in an email is GET. Would it be more secure for them to click on the link and then I redirect them on the backend to submit their “YES” or “NO” as a POST (where I can include a {%csrf_token %}? Can someone explain more how to do this and why this is a security hole? I was reading about this [here](https://code.djangoproject.com/ticket/7989)
c.If I wanted to include day of the week form, should I make them login to do this, or could this also be on the “Yes” page and they submit this <form>without logging in? I figure if every 2 weeks we change the temporary_user_id, this is reasonably secure since no one in the public could find this page (we will use multiple uuids). Am I at risk of some injection attack here?
/r/django
https://redd.it/7ll31b
Help: How to Design Models for Pairwise Matching of Users with Given Score?
I’m working on a dating app for a hackathon project. We have a series of questions that users fill out, and then every few days we are going to send suggested matches. If anyone has a good tutorial for these kinds of matching algorithms, it would be very appreciated. One idea is to assign a point value for each question and then to do a
def comparison(person_a, person_b) function where you iterate through these questions, and where there’s a common answer, you add in a point. So the higher the score, the better the match. I understand this so far, but I’m struggling to see how to save this data in the database.
In python, I could take each user and then iterate through all the other users with this comparison function and make a dictionary for each person that lists all the other users and a score for them. And then to suggest matches, I iterate through the dictionary list and if that person hasn’t been matched up already with that person, then make a match.
person1_dictionary_of_matches = {‘person2’: 3, ‘person3’: 5, ‘person4’: 10, ‘person5’: 12, ‘person6’: 2,……,‘person200’:10}
person_1_list_of_prior_matches = [‘person3’, 'person4']
I'm struggling on how to represent this in django. I could have a bunch of users and make a Match model like:
class Match(Model):
person1 = models.ForeignKey(User)
person2 = models.ForeignKey(User)
score = models.PositiveIntegerField()
Where I do the iteration and save all the pairwise scores.
and then do
person_matches = Match.objectsfilter(person1=sarah, person2!=sarah).order_by('score').exclude(person2 in list_of_past_matches)
But I’m worried with 1000 users, I will have 1000000 rows in my table if do this. Will this be brutal to have to save all these pairwise scores for each user in the database? Or does this not matter if I run it at like Sunday night at 1am or just cache these responses once and use the comparisons for a period of months? Is there a better way to do this than matching everyone up pairwise? Should I use some other data structure to capture the people and their compatibility score? Thanks so much for any guidance!
/r/django
https://redd.it/7lmzqa
I’m working on a dating app for a hackathon project. We have a series of questions that users fill out, and then every few days we are going to send suggested matches. If anyone has a good tutorial for these kinds of matching algorithms, it would be very appreciated. One idea is to assign a point value for each question and then to do a
def comparison(person_a, person_b) function where you iterate through these questions, and where there’s a common answer, you add in a point. So the higher the score, the better the match. I understand this so far, but I’m struggling to see how to save this data in the database.
In python, I could take each user and then iterate through all the other users with this comparison function and make a dictionary for each person that lists all the other users and a score for them. And then to suggest matches, I iterate through the dictionary list and if that person hasn’t been matched up already with that person, then make a match.
person1_dictionary_of_matches = {‘person2’: 3, ‘person3’: 5, ‘person4’: 10, ‘person5’: 12, ‘person6’: 2,……,‘person200’:10}
person_1_list_of_prior_matches = [‘person3’, 'person4']
I'm struggling on how to represent this in django. I could have a bunch of users and make a Match model like:
class Match(Model):
person1 = models.ForeignKey(User)
person2 = models.ForeignKey(User)
score = models.PositiveIntegerField()
Where I do the iteration and save all the pairwise scores.
and then do
person_matches = Match.objectsfilter(person1=sarah, person2!=sarah).order_by('score').exclude(person2 in list_of_past_matches)
But I’m worried with 1000 users, I will have 1000000 rows in my table if do this. Will this be brutal to have to save all these pairwise scores for each user in the database? Or does this not matter if I run it at like Sunday night at 1am or just cache these responses once and use the comparisons for a period of months? Is there a better way to do this than matching everyone up pairwise? Should I use some other data structure to capture the people and their compatibility score? Thanks so much for any guidance!
/r/django
https://redd.it/7lmzqa
reddit
Help: How to Design Models for Pairwise Matching of... • r/django
I’m working on a dating app for a hackathon project. We have a series of questions that users fill out, and then every few days we are going to...
[P] PyTorch Implementation of VQA Challenge 2017 Winner: Bottom-Up and Top-Down Attention for Visual Question Answering
https://github.com/hengyuan-hu/bottom-up-attention-vqa
/r/MachineLearning
https://redd.it/7llkgb
https://github.com/hengyuan-hu/bottom-up-attention-vqa
/r/MachineLearning
https://redd.it/7llkgb
GitHub
GitHub - hengyuan-hu/bottom-up-attention-vqa: An efficient PyTorch implementation of the winning entry of the 2017 VQA Challenge.
An efficient PyTorch implementation of the winning entry of the 2017 VQA Challenge. - GitHub - hengyuan-hu/bottom-up-attention-vqa: An efficient PyTorch implementation of the winning entry of the 2...
Help: Designing Models for Matches in a Dating App?
I’m working on a dating app for a hackathon project. We have a series of questions that users fill out, and then every few days we are going to send suggested matches. If anyone has a good tutorial for these kinds of matching algorithms, it would be very appreciated. One idea is to assign a point value for each question and then to do a
def comparison(person_a, person_b) function where you iterate through these questions, and where there’s a common answer, you add in a point. So the higher the score, the better the match. I understand this so far, but I’m struggling to see how to save this data in the database.
In python, I could take each user and then iterate through all the other users with this comparison function and make a dictionary for each person that lists all the other users and a score for them. And then to suggest matches, I iterate through the dictionary list and if that person hasn’t been matched up already with that person, then make a match.
person1_dictionary_of_matches = {‘person2’: 3, ‘person3’: 5, ‘person4’: 10, ‘person5’: 12, ‘person6’: 2,……,‘person200’:10}
person_1_list_of_prior_matches = [‘person3’, 'person4']
I'm struggling on how to represent this in django. I could have a bunch of users and make a Match model like:
class Match(Model):
person1 = models.ForeignKey(User)
person2 = models.ForeignKey(User)
score = models.PositiveIntegerField()
Where I do the iteration and save all the pairwise scores.
and then do
person_matches = Match.objectsfilter(person1=sarah, person2!=sarah).order_by('score').exclude(person2 in list_of_past_matches)
But I’m worried with 1000 users, I will have 1000000 rows in my table if do this. Will this be brutal to have to save all these pairwise scores for each user in the database? Or does this not matter if I run it at like Sunday night at 1am or just cache these responses once and use the comparisons for a period of months? Is there a better way to do this than matching everyone up pairwise? Should I use some other data structure to capture the people and their compatibility score? Thanks so much for any guidance!
/r/django
https://redd.it/7lo21q
I’m working on a dating app for a hackathon project. We have a series of questions that users fill out, and then every few days we are going to send suggested matches. If anyone has a good tutorial for these kinds of matching algorithms, it would be very appreciated. One idea is to assign a point value for each question and then to do a
def comparison(person_a, person_b) function where you iterate through these questions, and where there’s a common answer, you add in a point. So the higher the score, the better the match. I understand this so far, but I’m struggling to see how to save this data in the database.
In python, I could take each user and then iterate through all the other users with this comparison function and make a dictionary for each person that lists all the other users and a score for them. And then to suggest matches, I iterate through the dictionary list and if that person hasn’t been matched up already with that person, then make a match.
person1_dictionary_of_matches = {‘person2’: 3, ‘person3’: 5, ‘person4’: 10, ‘person5’: 12, ‘person6’: 2,……,‘person200’:10}
person_1_list_of_prior_matches = [‘person3’, 'person4']
I'm struggling on how to represent this in django. I could have a bunch of users and make a Match model like:
class Match(Model):
person1 = models.ForeignKey(User)
person2 = models.ForeignKey(User)
score = models.PositiveIntegerField()
Where I do the iteration and save all the pairwise scores.
and then do
person_matches = Match.objectsfilter(person1=sarah, person2!=sarah).order_by('score').exclude(person2 in list_of_past_matches)
But I’m worried with 1000 users, I will have 1000000 rows in my table if do this. Will this be brutal to have to save all these pairwise scores for each user in the database? Or does this not matter if I run it at like Sunday night at 1am or just cache these responses once and use the comparisons for a period of months? Is there a better way to do this than matching everyone up pairwise? Should I use some other data structure to capture the people and their compatibility score? Thanks so much for any guidance!
/r/django
https://redd.it/7lo21q
reddit
Help: Designing Models for Matches in a Dating App? • r/django
I’m working on a dating app for a hackathon project. We have a series of questions that users fill out, and then every few days we are going to...
An example of Django project with login, registration, password change, log out, and password reset functionality [UPDATE 3.0]
https://www.reddit.com/r/django/comments/7kwy9w/an_example_of_django_project_with_login/
/r/Python
https://redd.it/7lngr9
https://www.reddit.com/r/django/comments/7kwy9w/an_example_of_django_project_with_login/
/r/Python
https://redd.it/7lngr9
reddit
An example of Django project with login, registration,... • r/django
Links: - Repository: https://github.com/egorsmkv/simple-django-login-and-register - Previous post about 2.0 version:...
Python Top 10 Articles - Dec 2017
https://medium.com/@Mybridge/python-top-10-articles-for-the-past-month-v-dec-2017-20a36e77b3cc
/r/Python
https://redd.it/7lok73
https://medium.com/@Mybridge/python-top-10-articles-for-the-past-month-v-dec-2017-20a36e77b3cc
/r/Python
https://redd.it/7lok73
Medium
Python Top 10 Articles for the Past Month (v.Dec 2017)
For the past month, we ranked nearly 1,100 Python articles to pick the Top 10 stories that can help advance your career (0.9% chance).
A mini-tutorial on deploying smart contracts with python
I wanted to learn smart contract development for work and started off with a simple tutorial that was in javascript. To challenge myself I started converting the tutorial to python.
https://github.com/adamyala/Your_First_Decentralized_Application_Python
I tried to make it as simple as possible and added lots of notes I wish I had when I was learning.
I'd love to know if there is anything I can add/change to make it clearer and more simple. My goal is to eventually convert the entire thing to 100% python.
/r/Python
https://redd.it/7lr48g
I wanted to learn smart contract development for work and started off with a simple tutorial that was in javascript. To challenge myself I started converting the tutorial to python.
https://github.com/adamyala/Your_First_Decentralized_Application_Python
I tried to make it as simple as possible and added lots of notes I wish I had when I was learning.
I'd love to know if there is anything I can add/change to make it clearer and more simple. My goal is to eventually convert the entire thing to 100% python.
/r/Python
https://redd.it/7lr48g
GitHub
GitHub - adamyala/Your_First_Decentralized_Application_Python: An up to date and bare minimum tutorial on deploying smart contracts…
An up to date and bare minimum tutorial on deploying smart contracts with python - adamyala/Your_First_Decentralized_Application_Python
[D] What ML publication hacks are you familiar with, and which annoy you the most?
This is in line with "When a measure becomes a target, it ceases to be a good measure."
In ML literature (and other literature, especially academic) the measure/target is 'good reviews from reviewers'.
So which publication hacks are you familiar with, and which annoy you the most?
I'll start, motivated by a comment from https://github.com/hengyuan-hu/bottom-up-attention-vqa :
> The third point is simply because we feel the two stream classifier and pre-training in the original paper is over-complicated and not necessary.
Hack: Begin complex, and do not 'waste' your time with ablation studies / trying to simplify.
Reason this improves the measure/target: Reviewers will more often complain about simplicity ('incremental research') than complexity.
Reason this sucks for everyone involved except the authors: Leads to overly complex models, with little to no understanding of which components are actually useful.
Edit: Fixed URL
/r/MachineLearning
https://redd.it/7lq58j
This is in line with "When a measure becomes a target, it ceases to be a good measure."
In ML literature (and other literature, especially academic) the measure/target is 'good reviews from reviewers'.
So which publication hacks are you familiar with, and which annoy you the most?
I'll start, motivated by a comment from https://github.com/hengyuan-hu/bottom-up-attention-vqa :
> The third point is simply because we feel the two stream classifier and pre-training in the original paper is over-complicated and not necessary.
Hack: Begin complex, and do not 'waste' your time with ablation studies / trying to simplify.
Reason this improves the measure/target: Reviewers will more often complain about simplicity ('incremental research') than complexity.
Reason this sucks for everyone involved except the authors: Leads to overly complex models, with little to no understanding of which components are actually useful.
Edit: Fixed URL
/r/MachineLearning
https://redd.it/7lq58j
GitHub
GitHub - hengyuan-hu/bottom-up-attention-vqa: An efficient PyTorch implementation of the winning entry of the 2017 VQA Challenge.
An efficient PyTorch implementation of the winning entry of the 2017 VQA Challenge. - GitHub - hengyuan-hu/bottom-up-attention-vqa: An efficient PyTorch implementation of the winning entry of the 2...
Fastest way to uniquify a list in Python >=3.6
https://www.peterbe.com/plog/fastest-way-to-uniquify-a-list-in-python-3.6
/r/Python
https://redd.it/7lqu97
https://www.peterbe.com/plog/fastest-way-to-uniquify-a-list-in-python-3.6
/r/Python
https://redd.it/7lqu97
Evolving Simple Organisms using a Genetic Algorithm and Deep Learning from Scratch with Python – nathanrooy.github.io
https://nathanrooy.github.io/posts/2017-11-30/evolving-simple-organisms-using-a-genetic-algorithm-and-deep-learning/?utm_source=mybridge&utm_medium=blog&utm_campaign=read_more
/r/Python
https://redd.it/7lshtb
https://nathanrooy.github.io/posts/2017-11-30/evolving-simple-organisms-using-a-genetic-algorithm-and-deep-learning/?utm_source=mybridge&utm_medium=blog&utm_campaign=read_more
/r/Python
https://redd.it/7lshtb
nathanrooy.github.io
Evolving Simple Organisms using a Genetic Algorithm and Deep Learning from Scratch with Python
Nathan A. Rooy | nathanrooy.github.io
How do I create a checkbox using model fields?
I have to create a field in a model, what field class can I use to represent the checkbox? How can I use this in the Modelform?
/r/django
https://redd.it/7lurgg
I have to create a field in a model, what field class can I use to represent the checkbox? How can I use this in the Modelform?
/r/django
https://redd.it/7lurgg
reddit
How do I create a checkbox using model fields? • r/django
I have to create a field in a model, what field class can I use to represent the checkbox? How can I use this in the Modelform?
notifiers 0.6.0 released. 4 new notifiers, a total of 9 and going strong
https://github.com/liiight/notifiers
/r/Python
https://redd.it/7luntc
https://github.com/liiight/notifiers
/r/Python
https://redd.it/7luntc
GitHub
GitHub - liiight/notifiers: The easy way to send notifications
The easy way to send notifications. Contribute to liiight/notifiers development by creating an account on GitHub.
The state of Python 3 adoption
https://rushter.com/blog/python-3-adoption/
/r/Python
https://redd.it/7lwxxf
https://rushter.com/blog/python-3-adoption/
/r/Python
https://redd.it/7lwxxf
[AF] SocketIO -- Server not opening websocket connection
Hi, I'm trying to run a (very) simple websocket server.
I'm trying to connect using a command line tool:
> $ wscat -c ws://localhost:5000/
Starting the server, and running the *wscat* request, I see:
* Serving Flask-SocketIO app "main"
* Forcing debug mode on
* Restarting with stat
* Debugger is active!
* Debugger PIN: 243-427-340
(1983) wsgi starting up on http://127.0.0.1:5000
(1983) accepted ('127.0.0.1', 50372)
127.0.0.1 - - [24/Dec/2017 09:19:18] "GET / HTTP/1.1" 200 132 0.003266
It's making the http connection, but doesn't seem to be promoting to websockets. There's a debugging "print" doesn't print, and an "emit" that doesn't emit for the "connect".
I can use *wscat* to connect to echo servers just fine.
I'm clearly not doing something right, I'm just really not sure what!
I've tried with web pages too -- but here I'm trying to keep it simple.
[GitHub app](https://github.com/hanhanhan/fake_bus_api/blob/ws_troubleshoot/main.py)
[conda installed requirements](https://github.com/hanhanhan/fake_bus_api/blob/ws_troubleshoot/requirements_conda.txt)
[pip installed requirements](https://github.com/hanhanhan/fake_bus_api/blob/ws_troubleshoot/requirements.txt)
I'd really appreciate another pair of eyes, if anyone has troubleshooting advice or can see a bug.
Thanks, and Happy Christmas!
EDIT:
I just tried running Miguel Grinberg's Flask-SocketIO off of github, but with the same environment I was running my own test with.
It works!
Though some of the responses are labelled polling, and some are websockets, which seems funny to me that it's doing both in the same browser.
But this confirms it's me not seeing / understanding some concept.
127.0.0.1 - - [24/Dec/2017 14:43:40] "GET / HTTP/1.1" 200 6028 0.001638
127.0.0.1 - - [24/Dec/2017 14:43:40] "GET /socket.io/?EIO=3&transport=polling&t=1514144620687-0 HTTP/1.1" 200 381 0.001277
(2632) accepted ('127.0.0.1', 51051)
Client disconnected 19392765e6d8415f9c2654d2cf924186
127.0.0.1 - - [24/Dec/2017 14:47:18] "GET /socket.io/?EIO=3&transport=websocket&sid=19392765e6d8415f9c2654d2cf924186 HTTP/1.1" 200 0 217.415311
/r/flask
https://redd.it/7lvfuh
Hi, I'm trying to run a (very) simple websocket server.
I'm trying to connect using a command line tool:
> $ wscat -c ws://localhost:5000/
Starting the server, and running the *wscat* request, I see:
* Serving Flask-SocketIO app "main"
* Forcing debug mode on
* Restarting with stat
* Debugger is active!
* Debugger PIN: 243-427-340
(1983) wsgi starting up on http://127.0.0.1:5000
(1983) accepted ('127.0.0.1', 50372)
127.0.0.1 - - [24/Dec/2017 09:19:18] "GET / HTTP/1.1" 200 132 0.003266
It's making the http connection, but doesn't seem to be promoting to websockets. There's a debugging "print" doesn't print, and an "emit" that doesn't emit for the "connect".
I can use *wscat* to connect to echo servers just fine.
I'm clearly not doing something right, I'm just really not sure what!
I've tried with web pages too -- but here I'm trying to keep it simple.
[GitHub app](https://github.com/hanhanhan/fake_bus_api/blob/ws_troubleshoot/main.py)
[conda installed requirements](https://github.com/hanhanhan/fake_bus_api/blob/ws_troubleshoot/requirements_conda.txt)
[pip installed requirements](https://github.com/hanhanhan/fake_bus_api/blob/ws_troubleshoot/requirements.txt)
I'd really appreciate another pair of eyes, if anyone has troubleshooting advice or can see a bug.
Thanks, and Happy Christmas!
EDIT:
I just tried running Miguel Grinberg's Flask-SocketIO off of github, but with the same environment I was running my own test with.
It works!
Though some of the responses are labelled polling, and some are websockets, which seems funny to me that it's doing both in the same browser.
But this confirms it's me not seeing / understanding some concept.
127.0.0.1 - - [24/Dec/2017 14:43:40] "GET / HTTP/1.1" 200 6028 0.001638
127.0.0.1 - - [24/Dec/2017 14:43:40] "GET /socket.io/?EIO=3&transport=polling&t=1514144620687-0 HTTP/1.1" 200 381 0.001277
(2632) accepted ('127.0.0.1', 51051)
Client disconnected 19392765e6d8415f9c2654d2cf924186
127.0.0.1 - - [24/Dec/2017 14:47:18] "GET /socket.io/?EIO=3&transport=websocket&sid=19392765e6d8415f9c2654d2cf924186 HTTP/1.1" 200 0 217.415311
/r/flask
https://redd.it/7lvfuh
GitHub
hanhanhan/fake_bus_api
Contribute to fake_bus_api development by creating an account on GitHub.