Skip to content

Instantly share code, notes, and snippets.

@openfly
Created September 18, 2017 14:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save openfly/bf7d1c17e87748a95de2fa4ffd352890 to your computer and use it in GitHub Desktop.
Save openfly/bf7d1c17e87748a95de2fa4ffd352890 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import sys
from flask import Flask, Blueprint
from flask_restplus import Api
from werkzeug.contrib.fixers import ProxyFix
# threw this in to see if there were any exceptions here. there were not.
try:
from harpsichord.Api import MongoisMaster
from harpsichord.Api.search import SearchbyId
from harpsichord.Api.search import SearchbyName
except Exception as exceptor:
print exceptor
sys.exit(2)
app = Flask(__name__)
app.wsgi_app = ProxyFix(app.wsgi_app)
api = Api(app)
# none of this works when in uwsgi. no errors. just endpoints don't register. swagger shows up without em
def initialize_app(app):
api.add_resource(MongoisMaster, '/mongo', '/mongo/isMaster')
api.add_resource(SearchbyId, '/search/userid', '/search/userid')
api.add_resource(SearchbyName, '/search/username', '/search/username')
if __name__ == '__main__':
initialize_app(app)
# this did not work
# app.wsgi_app = ProxyFix(app.wsgi_app)
app.run(debug=True, host='0.0.0.0')
# when running standalone i specify a port
# app.run(debug=True, host='0.0.0.0', port=6500)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment