Skip to content

Javascript Notes (Backend)

j-sawn edited this page May 21, 2025 · 6 revisions

BACKEND


Pt. 1 - Django

Installation and Set-Up

  • Open your Python environment
source ./app/venv/bin/activate
  • Then, install Django using the following:
pip install django
  • Now, to start off, you should make your own project. You can do this by running this in your terminal:
django-admin startproject [INSERT NAME OF PROJECT]
  • For convenience, switch to the project folder
cd [INSERT NAME OF PROJECT]
  • And try and run it on the host:
python manage.py runserver 0.0.0.0:7860

You should get this upon visiting http://localhost:7860/: image (otherwise, you might need to debug!)

Making Pages

python manage.py startapp [INSERT NAME OF APP]

This will create a folder within your project folder (my app is called "first_test" while my project is called "modelworks_chatbot"

image

To edit what you want to see, go to [INSERT NAME OF APP]/views.py. There is substantial documentation on how to do this, but for simplicity this wiki follows the w3schools guide and uses the following code:

from django.shortcuts import render
from django.http import HttpResponse

def members(request):
    return HttpResponse("Hello world!")

To link what you wrote to the host:

  • Create a new file within the APP folder: urls.py
  • Copy and paste in the following:
from django.urls import path
from . import views

urlpatterns = [
    path('[INSERT NAME OF APP]/', views.[INSERT NAME OF APP], name='[INSERT NAME OF APP]'),
]
  • Go back to the main project folder and go to its urls.py file
  • Add the following to its urlpatterns array:
    • path('', include('[INSERT NAME OF APP].urls')),
    • It should look like this:
from django.contrib import admin
from django.urls import include, path

urlpatterns = [
    path('', include('members.urls')),
    path('admin/', admin.site.urls),
]

Now, you can see your work on the host by running it:

python manage.py runserver 0.0.0.0:7860

Then go to http://localhost:7860/[INSERT NAME OF APP] to access what you wrote in [INSERT NAME OF APP]/views.py image

Other Language Integration

(wip)


Pt. 2 - Flask

Installation and Set-Up

  • Open your Python environment
source ./app/venv/bin/activate
  • Then, install Flask using the following:
pip install flask

Pt. 3 - FastAPI

[need to insert how we got this working]


FINAL CHOICE

Option recommended currently working on all devices easy to set up Final
Django - - + -1
Flask + (Elena) - - -1
FastAPI + (Elena) + + 3

Ultimately, FastAPI was the only framework that was the best for all team members, hence it was chosen for our backend.

Clone this wiki locally