Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Add basic endpoint for sending missing info #2

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ name = "pypi"
[packages]
flask-restplus = "*"
dataclasses = "*"
flask-cors = "*"

[dev-packages]
pytest = "*"
Expand Down
5 changes: 4 additions & 1 deletion thankful_server/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,20 @@

from flask import Flask
from flask_restplus import Api
from flask_cors import CORS

from . import __version__
from .rest import creators, thanks
from .rest import creators, thanks, missing

app = Flask(__name__)
CORS(app)
api = Api(app, version=__version__, title='Thankful Server API',
description='An API for getting information about creators')
# TODO: Do some fancy stuff with blueprints to handle versions

api.add_namespace(creators.api)
api.add_namespace(thanks.api)
api.add_namespace(missing.api)


def main() -> None:
Expand Down
34 changes: 34 additions & 0 deletions thankful_server/rest/missing.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
from sys import version_info

from flask import request
from flask_restplus import Namespace, Resource, fields

# Backport
if (3, 5) <= version_info < (3, 7):
from dataclasses import dataclass
elif version_info < (3, 6):
raise Exception("Incompatible Python version")

api = Namespace('missing', description='For telling us about creators without' +
'addresses')

missingModel = api.model('Missing', {
#'creator_url': fields.Url(required=True, description='The creator url,' +
# ' at least for this website'),
'missing_info': fields.Raw(required=True, description='JSON')
#'donation_amount': fields.Float(required=False, description='The amount' +
# ' that the user wanted to donate'),
})


@api.route('/')
class MissingResource(Resource):
'''beep boop documentation'''

@api.doc('thank_creator')
@api.param('missing_info', help="The json")
def post(self):
info = request.args["missing_info"]
# TODO: Do fancier logging here
print(info)
return 'thx'