Skip to content

technosophos/example-router-py

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

A simple Spin HTTP component in Python

This project showcases how to do internal HTTP routing in a Spin Python application. It is similar to the Spin JS router as well as the Django router.

If you are interested in extrnal routing (where the routing table is declared in the spin.toml), the Application Structure guide covers this, as does the documentation for Spin configuration.

This uses the absolutely fantastic http_router project. You will likely want to reference the API docs:

Prerequisites

Installing

  • Install the dependencies with pipenv update
  • Build with spin build
$ pipenv update
$ spin build

Running

Locally

$ spin up

You can then try out some example queries:

  • curl localhost:3000/
  • curl -XPOST -d "TEST" localhost:3000/post
  • curl localhost:3000/queryparams\?foo=bar\&foo2=bar2

On Fermyon Cloud

$ spin deploy

You can then adapt the above curl requests to the URL Fermyon Cloud returned to you.

About

Example of a Python Spin application with an internal http_router-based router

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages