forked from kennethreitz/responder
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.py
66 lines (46 loc) · 1.18 KB
/
app.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
import responder
import graphene
from flask import Flask
app = Flask(__name__)
@app.route("/")
def hello_world():
return "Hello, World from flask!"
api = responder.API(enable_hsts=False)
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, graphiql=True)
print(
api.session()
.get(
"http://app/",
# 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)