0

I developed my restful api flask project (let's call it 'MYOWN').

And then, because of some needs to implement functions like 'notification', 'chat', and so on, I tried to merge my project with simple socketIO example project.

I want to run my project with only one command below

> ./manage.py runserver

In 'MYOWN's manage.py script, there exist

if __name__=='__main__':
    manager.run()

and it made me confused with "where do I insert script below to 'MYOWN'?".

socketio.run(app)

Is there any way to run 'MYOWN' and socketIO example project same time?

Chris Martin
  • 30,334
  • 10
  • 78
  • 137
HT.Cha
  • 13
  • 4

1 Answers1

0

Flask-Script's runserver command is not compatible with Flask-SocketIO. If you want to start your server with Flask-Script you have to write a new version of runserver. A simple replacement could be:

@manager.command
def runserver():
    socketio.run()

Of course you can add any arguments you need, but not that some of the arguments are different between app.run() and socketio.run.

Miguel Grinberg
  • 65,299
  • 14
  • 133
  • 152