FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
grpc-web-python-example/server.py at main · gitpushdashf/grpc-web-python-example · GitHub
gitpushdashf
grpc-web-python-example
Repository navigation
Code
Issues
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
grpc-web-python-example
/
server.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
39 lines (27 loc) · 1 KB
Breadcrumbs
grpc-web-python-example
/
server.py
Copy path
File metadata and controls
39 lines (27 loc) · 1 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
from
flask
import
Flask
,
send_from_directory
from
sonora
.
wsgi
import
grpcWSGI
import
helloworld_pb2
import
helloworld_pb2_grpc
FORMAT_STRING
=
"Hello, {request.name}"
app
=
Flask
(
__name__
)
class
Greeter
(
helloworld_pb2_grpc
.
GreeterServicer
):
def
SayHello
(
self
,
request
,
context
):
print
(
f"We are saying hello to
{
request
.
name
}
"
)
return
helloworld_pb2
.
HelloReply
(
message
=
FORMAT_STRING
.
format
(
request
=
request
))
def
SayRepeatHello
(
self
,
request
,
context
):
return
helloworld_pb2
.
HelloReply
(
message
=
FORMAT_STRING
.
format
(
request
=
request
)
*
request
.
count
)
@
app
.
route
(
"/"
)
def
index
():
return
send_from_directory
(
"."
,
"index.html"
)
@
app
.
route
(
"/<path:path>"
)
def
foo
(
path
):
if
path
==
"/"
:
path
=
"index.html"
# This appears to filter ../ for us.
return
send_from_directory
(
"."
,
path
)
if
__name__
==
"__main__"
:
app
.
wsgi_app
=
grpcWSGI
(
app
.
wsgi_app
)
helloworld_pb2_grpc
.
add_GreeterServicer_to_server
(
Greeter
(),
app
.
wsgi_app
)
app
.
run
()
Back
|
FazBrowse Home
|
New Git URL