Skip to content

Fast MicroPython Web API Framework inpired by awesome FastApi project

License

Notifications You must be signed in to change notification settings

amirivojdan/MicroFastApi

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MicroFastApi

Fast MicroPython Web API Framework inpired by awesome FastApi project.

from microfastapi import MicroFastApi
from wifi import Wifi
from secrets import *
import machine

machine.freq(133000000) # set the CPU frequency to 133 MHz(max)

wifihandle = Wifi(ssid = ssid, password = password)

if not wifihandle.connect(powersavingmode=False):
    raise Exception("Connection failed!")

print("\n",wifihandle,"\n")

app = MicroFastApi(ip= wifihandle.ip, port=80, mac= wifihandle.mac)
    
@app.get('/')
def index():
    return {'userId': 1}   

@app.get('/sensors/')
def sensors(userId:int=None):
    return {'userId':'1'}

app.Run()
Connecting to: XXXXX
Waiting for WiFi connection...
Connected: True

 -- Network settings -- 
Wifi SSID: XXXXX
IP Addr: 10.0.0.67
Mac Addr: xx:xx:xx:xx:xx:xx
Net Mask: XXXX
DHCP: XXXX 
DNS Server: XXXX
Status: Connected 

API server running on http://10.0.0.67:80
client connected from ('10.0.0.30', 49992)
client closed!
{"userId": "1"}

About

Fast MicroPython Web API Framework inpired by awesome FastApi project

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages