Running an HTTP & GRPC python server concurrently on AWS Elastic

Running an HTTP & GRPC python server concurrently on AWS Elastic

Practical guide to developing and deploying python servers. I will be using the async python web framework AIOHTTP. In case that you may not have heard or used it before I would advice you to jump quickly to the official documentation here and briefly skim through the introduction.

I will be using the async python web framework AIOHTTP. In case that you may not have heard or used it before I would advice you to jump quickly to the official documentation here and briefly skim through the introduction.

All the code used in this tutorial is also on [github_](https://github.com/wlwanpan/medium/tree/master/aiohttp-grpc-ebs)._

HTTP

Lets start off with the HTTP server! I am going to use [email protected] and pipenv as my package manager and virtual environment but feel free to use any other tool that you might be familiar with. Run the following to start a new python3 environment:

pipenv --python 3.7

Before writing any code, we need to first install our dependencies. For the time being, aiohttp will suffice to get the HTTP server up and running. so lets install it:

pipenv install aiohttp

Now we can start off with our Application class.

## application.py

from aiohttp import web

class Application(web.Application):
    def __init__(self):
        super().__init__()
    def run(self):
        return web.run_app(self, port=8000)
application = Application()
if __name__ == '__main__':
    application.run()

On a quick note, you have to call the new application instance ‘application’ since elastic beanstalk expects that variable name by default when booting the app, direct quote of the docstring from on the official doc:

“EB looks for an ‘application’ callable by default.”

At this point you have a fully runnable web server:

python application.py

======== Running on http://0.0.0.0:8000 ========

elastic-beanstalk aws python aiohttp grpc

Bootstrap 5 Complete Course with Examples

Bootstrap 5 Tutorial - Bootstrap 5 Crash Course for Beginners

Nest.JS Tutorial for Beginners

Hello Vue 3: A First Look at Vue 3 and the Composition API

Building a simple Applications with Vue 3

Deno Crash Course: Explore Deno and Create a full REST API with Deno

How to Build a Real-time Chat App with Deno and WebSockets

Convert HTML to Markdown Online

HTML entity encoder decoder Online

Running an HTTP & GRPC python server concurrently on AWS elastic

Getting started with AIOHTTP & GRPC server! I will be using the async python web framework AIOHTTP. In case that you may not have heard or used it before I would advice you to jump quickly to the official documentation here and briefly skim through the introduction.

Python Tricks Every Developer Should Know

In this tutorial, you’re going to learn a variety of Python tricks that you can use to write your Python code in a more readable and efficient way like a pro.

How to Remove all Duplicate Files on your Drive via Python

Today you're going to learn how to use Python programming in a way that can ultimately save a lot of space on your drive by removing all the duplicates. We gonna use Python OS remove( ) method to remove the duplicates on our drive. Well, that's simple you just call remove ( ) with a parameter of the name of the file you wanna remove done.

How to Deploy a Spring Boot App to AWS Elastic Beanstalk

In this post, we are going to explore how we can deploy a simple Spring Boot application to AWS Elastic Beanstalk. We will explain how to setup an AWS account and provide a step-by-step guide how to deploy to AWS. ### 1\. Introduction AWS...

Basic Data Types in Python | Python Web Development For Beginners

In the programming world, Data types play an important role. Each Variable is stored in different data types and responsible for various functions. Python had two different objects, and They are mutable and immutable objects.