Developer Documentation
  • Documentation Overview
  • Development Introduction
  • Getting Started
  • Fundamentals
    • Deploy an App via Pre-defined Sidecar
      • Sidecar Tutorial: Server-side
      • Sidecar Tutorial: Client-side
      • Sidecar Tutorial: Docker & Deploy
    • Deploy an App with Eureka
    • Design Guidance
  • Authentication
    • Accessing data exposed by the platform
    • Single Sign-On
      • Angular
      • Vue
      • Java Spring: Accepting JWT
      • Python Django: Accepting JWT
    • User and Role Identification
  • APIs | Data Integration
    • Submodel Index
    • Masterdata
    • Transactional data
  • Docker Information
    • Ruby Stack
    • Golang Stack
    • Node JS Stack
    • Java Spring Stack
    • Python Stack
  • Connect to the Platform
    • Integrate using Eureka Rest APIs
    • Use our Pre-built sidecar
    • Production deployment
  • Add-on Features
    • IApps-Navigation
  • Testing
  • FAQs | Troubleshooting
  • Registration
    • Application pre-requisites
      • Basic Requirements
    • Register Developer Account
    • Submit basic application info
    • Onboard Application
      • Submit Appstore details
        • App basic information
      • Configure Application
        • App Permission
        • App Data
        • AAS Instance
        • Licensing
        • Access Rights
        • Account Info
        • Terms Of Use
        • Pricing
      • Publish and test
        • Deploy
        • Register into Service Discovery
    • Publish to Marketplace
  • User Experience
  • The business model - How do I get paid?
  • References
    • IndustryApps - Intro
    • What is an Asset Administration Shell?
    • What is ECLASS?
      • How is ECLASS and Concept dictionary are used
    • Industry 4.0 standards
    • Customer Terms of Use
      • Subscription Order
    • Solution provider Terms of Use
      • Contract regions
      • Submission Form ( Solution provider)
Powered by GitBook
On this page
  1. Fundamentals
  2. Deploy an App via Pre-defined Sidecar

Sidecar Tutorial: Server-side

Python 3.10 Is required to follow the Quick Start Tutorial.

In this part of the Quick Start tutorial, the server-side API will be made. Follow the steps below to complete the server-side tutorial.

Create a directory for your application project:

QuickApp

Inside the project directory create a directory named server and create:

  • requirements.txt

fastapi
uvicorn

In terminal cd into server directory and run commands:

# Create virtual environment for python project.
python -m venv venv
# Activate virtual environment
source venv/bin/activate 
# install required dependencies
pip install -r requirements.txt

Once these commands have been executed and dependencies have been installed, create and copy in the main.py file as illustrated below:

main.py
# FastApi Setup for the Quick Start Tutorial
from fastapi import FastAPI
from fastapi.middleware.cors import CORSMiddleware
import uvicorn

# Initiates the FastApi instance
app = FastAPI()

# Enabling CORS to allow access for the Client-side App.
app.add_middleware(
    CORSMiddleware,
    allow_origins=["*"],
    allow_credentials=True,
    allow_methods=["*"],
    allow_headers=["*"],
)

# Route for our API on index page to send over a simple message.
@app.get("/")
async def index():
    return {"message": "Welcome to IndustryApps!"}

This is a minimal setup to run a FastApi stateless Restful compliant API, this simply returns a message "Welcome to IndustryApps!" when fetched later on the client-side.

The command uvicorn main:app starts the API in case you'd like to test it, which refers to:

  • main: the file main.py (the Python "module").

  • app: the object created inside of main.py with the line app = FastAPI().

By following the link which pops up on terminal you should see the message displayed on the browser window:

FastApi automatically documents its endpoints. By adding /docs endpoint to your API url, the available endpoints of the API will be visible.

PreviousDeploy an App via Pre-defined SidecarNextSidecar Tutorial: Client-side

Last updated 2 years ago

The application will be built and run through docker-compose later in the tutorial. The next step will be building the client-side app with Vue /Nuxt js.

GET endpoint inside /docs of FastAPI