Created
October 10, 2018 11:54
-
-
Save kennethreitz/716ff444a51b54a69027fd77811587e1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import responder | |
import graphene | |
from flask import Flask | |
app = Flask(__name__) | |
@app.route("/") | |
def hello_world(): | |
return "Hello, World from flask!" | |
api = responder.API() | |
api.mount("/hello", app) | |
@api.route("/") | |
def hello(req, resp): | |
# resp.status = responder.status.ok | |
resp.content = api.template("test.html") | |
class ThingsResource: | |
def on_request(self, req, resp): | |
resp.status = responder.status.HTTP_200 | |
resp.media = ["yolo"] | |
class Query(graphene.ObjectType): | |
hello = graphene.String(name=graphene.String(default_value="stranger")) | |
def resolve_hello(self, info, name): | |
return "Hello " + name | |
schema = graphene.Schema(query=Query) | |
# Alerntatively, | |
api.add_route("/graph", schema) | |
print( | |
api.session() | |
.get( | |
"http://app/graph", | |
data="{ hello }", | |
headers={"Accept": "application/x-yaml"}, | |
# data="hello", | |
) | |
.text | |
) | |
# print( | |
# api.session() | |
# .get( | |
# "http://app/hello/", | |
# data="{ hello }", | |
# headers={"Accept": "application/x-yaml"}, | |
# # data="hello", | |
# ) | |
# .text | |
# ) | |
# {hello: Hello stranger} | |
# api.run(port=5000, expose_tracebacks=True) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment