#1 Changes in order to make the application run
Closed by abompard. Opened by atelic.
atelic/plus-plus-service master  into  master

Download 1.patch

Had to make some changes so that the app would run including:

  • remove all relative imports (found via ag -i '(from\ +\.\ *(\w+))|(import\ +\.\ *(\w+))') since they were causing errors
  • add the methods argument to @APP.route so that POST will work, flask will also return a 405 if it receives a request not in the list so remove the last if statement.
  • Call APP.run so I can make requests to the API

Also adds flake8 and style fixes.

Ah, right, that's been in my global gitignore file since forever :-)

I think that the relative import issues you're getting come from the fact that you're trying to run the app as a script. The Flask docs now recommend another way, see the very beginning of http://flask.pocoo.org/docs/0.11/quickstart/
Running "FLASK_APP=plus_plus_service flask run" works fine for me with the current code.

That is styling, I guess? PEP8 authorizes both ways. (at least flake8 does not report the current one).

Ah, right, thanks, I did not test the POST yet, it would have failed.

Agreed 100%, naming is important.

What's the rationale for this change? I thought PEP8 recommended imports to be sorted alphabetically?

Agreed again, I used the code from Supybot but full names are much better.

Since a lot of changes in this PR come from removing the relative imports, which actually came from a lack of documentation on my side (on how to run it), if you don't mind I'll just cherry-pick the other changes.

I realize that I pushed the code to give you an idea of its state but that it was still a bit early for other people to dig into it. Thanks for your input, I'll add more docs :-)

Hmm, if you move this in its own "app" module, then you'll have __name__ == plus_plus_service.app, right ?

Interesting, I had never heard of the flask run command. In that case you can cherry pick the changes you wish and I will close this. Thanks for the info! :)

Yeah, Pingou was surprised too, but it's apparently the recommended way to run it. I don't know if it's recent or not.

I've cherry-piked the changes, thanks for the MR.

Pull-Request has been closed by abompard

Metadata