Skip to content

Commit

Permalink
setting up webapp
Browse files Browse the repository at this point in the history
  • Loading branch information
Tiffany-Zhu5303 committed Jan 11, 2024
1 parent 5ad521f commit bc72702
Show file tree
Hide file tree
Showing 11 changed files with 52 additions and 2 deletions.
4 changes: 3 additions & 1 deletion main/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,6 @@
"""
from django.urls import include, path

urlpatterns = []
urlpatterns = [
path("api/", include("projectApp.urls")),
]
Empty file added projectApp/__init__.py
Empty file.
3 changes: 3 additions & 0 deletions projectApp/admin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from django.contrib import admin

# Register your models here.
6 changes: 6 additions & 0 deletions projectApp/apps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from django.apps import AppConfig


class ProjectappConfig(AppConfig):
default_auto_field = 'django.db.models.BigAutoField'
name = 'projectApp'
Empty file.
6 changes: 6 additions & 0 deletions projectApp/models.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from django.db import models

# Create your models here.

#class Molecule(models.Model):
#molecule = models.CharField(max_length=200)
10 changes: 10 additions & 0 deletions projectApp/templates/projectApp/get-molecules.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{% extends 'shared/base.html' %}
{% block content %}
<h1>Molecules</h1>
<form action="{% url 'inputMolecules' %}" method="post">
{% csrf_token %}
<label for="moleculeInput">Enter your molecule</label>
<textarea id="moleculeInput"></textarea>
<button class="btn btn-primary" type="submit">Submit</button>
</form>
{% endblock %}
3 changes: 3 additions & 0 deletions projectApp/tests.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from django.test import TestCase

# Create your tests here.
7 changes: 7 additions & 0 deletions projectApp/urls.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
from django.urls import path
from . import views

urlpatterns = [
path("getMolecules/", views.getMolecules, name="getMolecules"),
path("inputMolecules/", views.inputMolecules, name="inputMolecules")
]
11 changes: 11 additions & 0 deletions projectApp/views.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
from django.shortcuts import render
from django.http import HttpResponse

def getMolecules(request):
return render(request, "projectApp/get-molecules.html")

def inputMolecules(request):
molecule = request.POST.get("molecule")
print(molecule)
return HttpResponse("Recieved molecule!")

4 changes: 3 additions & 1 deletion shared/templates/shared/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@
<body>
<div class="w-100 h-100 overflow-auto d-flex flex-column justify-content-between">
<div class="container">
{% block content %}{% endblock %}
{% block content %}
{% endblock %}
</div>
<div>
{% block footer %}
Expand All @@ -37,6 +38,7 @@
</div>
</div>
<script>

const tooltipTriggerList = document.querySelectorAll('[data-bs-toggle="tooltip"]');
const tooltipList = [...tooltipTriggerList].forEach((tooltipTriggerEl) => {
new bootstrap.Tooltip(tooltipTriggerEl)
Expand Down

0 comments on commit bc72702

Please sign in to comment.