Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature Request] Add Django and FastAPI compatibility #13

Closed
marquesdavi opened this issue May 4, 2023 · 24 comments
Closed

[Feature Request] Add Django and FastAPI compatibility #13

marquesdavi opened this issue May 4, 2023 · 24 comments
Labels
enhancement New feature or request mojo-repo Tag all issues with this label

Comments

@marquesdavi
Copy link

Request

Add to Mojo, support for Python backend development frameworks like Django and FastAPI

Motivation

The same reason people use Python for backend development! You don't need to learn another programming language to be able to put your ideas on the internet

Description and Requirements

Be able to create RestAPIs, manage relational databases...

@Mogball Mogball added the enhancement New feature or request label May 4, 2023
@sa-
Copy link
Contributor

sa- commented May 6, 2023

Or providing an alternative webserver implementation (so that you don't have to use python unless you want to/have to) would also work. Happy to contribute here if needed!

@lattner
Copy link
Collaborator

lattner commented May 6, 2023

This is a great idea, but I'm not sure it is super actionable right now. Mojo can already talk to all the existing python apis, so these should (in principle) already work. I think the more interesting thing will be to develop mojo native apis for this use-case, which will be pretty epic. OTOH, this will be true for /tons/ of domains, and I don't think we should track all of them. We should keep building out the language and as it gets more filled out, we can explore these things.

Thank you for filing this though, super exciting time!

@lattner lattner closed this as completed May 6, 2023
@Bronya0
Copy link

Bronya0 commented Oct 10, 2023

so nice idea!

@west-github
Copy link

The man himself so happy about mojo and having great community 👏

@wasdee
Copy link

wasdee commented Jan 19, 2024

setup

python install via mise use python@3.11.7
i used it directly since poetry .venv don't create .so. ref #551
then pip install fastapi

result

today i can run

from python import Python
import sys

def main():
    fa = Python.import_module("fastapi")
    app = fa.FastAPI()

    print("FastAPI __version__:", fa.__version__)
~/UnixDev/fastapi-mojo is 📦 v0.1.0 via 🐍 v3.11.7 
❯ '/home/nam/.modular/pkg/packages.modular.com_mojo/bin/mojo' '/home/nam/UnixDev/fastapi-mojo/main.mojo'
FastAPI __version__: 0.109.0

on my WSL2 latest.

adding a route

from python import Python
import sys

def main():
    fa = Python.import_module("fastapi")
    app = fa.FastAPI()

    print("FastAPI __version__:", fa.__version__)

    @app.get("/")
    def read_root():
        return {"Hello": "World"}

this is not working. Below are errors.

'/home/nam/.modular/pkg/packages.modular.com_mojo/bin/mojo' '/home/nam/UnixDev/fastapi-mojo/main.mojo'
/home/nam/UnixDev/fastapi-mojo/main.mojo:2:5: error: unexpected tokens after decorator, each need to be on their own line
    def read_root():
    ^
/home/nam/UnixDev/fastapi-mojo/main.mojo:3:16: error: TODO: cannot emit dictionary literals yet
        return {"Hello": "World"}
               ^~~~~~~~~~~~~~~~~~
/home/nam/UnixDev/fastapi-mojo/main.mojo:1:2: error: use of unknown declaration 'app'
@app.get("/")
 ^~~
/home/nam/.modular/pkg/packages.modular.com_mojo/bin/mojo: error: failed to parse the provided Mojo

@danielegaliffa
Copy link

Why this issue is closed?

@wasdee
Copy link

wasdee commented Jan 26, 2024

Why this issue is closed?

idk. i should reopen i guess.

@k00000han
Copy link

k00000han commented Jan 31, 2024

It's will be great if we could to use Mojo for backend development with FastAPI/Django the way people use Typescript with React/Vue/Node/ etc.

@wasdee
Copy link

wasdee commented Feb 6, 2024

It's will be great if we could to use Mojo for backend development with FastAPI/Django the way people use Typescript with React/Vue/Node/ etc.

I am expecting similar phenomenal like Elysia typescript on bun-zig.

I want to see/make a new pythonic fastest web framework on planet.

@munjed-ab
Copy link

I am so excited for this 🔥

@GokuSy
Copy link

GokuSy commented Feb 26, 2024

Is this issue resolved ?

I'm transitioning from Python to Mojo and would like guidance on setting up an endpoint with Mojo.

@Pyroseza
Copy link

What's happening here? Why is this closed, does it work with both FastAPI and Django?

@alew3
Copy link

alew3 commented Mar 26, 2024

API Endpoints are very important for ML/AI workflows or any web app for that matter. This should be prioritized IMHO.

@Warrio111
Copy link

This is high prio from my point of view

@tares003
Copy link

tares003 commented Apr 6, 2024

Looking forward to this!!!

@leejongheon42
Copy link

looking forward to this too

@ArunJRK
Copy link

ArunJRK commented May 2, 2024

Looking forward to this. It could entirely change the way we build backends. At least just FastAPI support will be great.

@ematejska ematejska added the mojo-repo Tag all issues with this label label May 7, 2024
@danieljohnmorris
Copy link

Why is this closed?

@KyoungsueKim
Copy link

Looking forward to this too. The reason have been already enriched by above peoples.

@JudeDavis1
Copy link

+1!!!

@imitelis
Copy link

I'm currently planning to migrate my FastAPI servers into Mojo too.

@h3llf1r33
Copy link

any updates ?

@abelkm99
Copy link

Commenting cause I also want that to happen.

@Pyroseza
Copy link

@lattner, can you please consider re-opening this so that when the time is right it can be worked on, instead of being closed an buried?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request mojo-repo Tag all issues with this label
Projects
None yet
Development

No branches or pull requests