Skip to content

Commit

Permalink
routing to html pages works!!!
Browse files Browse the repository at this point in the history
  • Loading branch information
group117 committed Jul 6, 2024
1 parent 0560a93 commit af9cc29
Show file tree
Hide file tree
Showing 9 changed files with 22 additions and 8 deletions.
Binary file modified backend/api/__pycache__/models.cpython-310.pyc
Binary file not shown.
Binary file modified backend/api/__pycache__/views.cpython-310.pyc
Binary file not shown.
9 changes: 6 additions & 3 deletions backend/api/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@
# You'll have to do the following manually to clean this up:
# * Rearrange models' order
# * Make sure each model has one field with primary_key=True
# * Make sure each ForeignKey and OneToOneField has `on_delete` set to the desired behavior
# * Remove `managed = False` lines if you wish to allow Django to create, modify, and delete the table
# * Make sure each ForeignKey and OneToOneField has `on_delete`
# * set to the desired behavior
# * Remove `managed = False` lines if you wish to allow Django
# * to create, modify, and delete the table
# Feel free to rename the models, but don't rename db_table values or field names.
from django.db import models

Expand Down Expand Up @@ -42,7 +44,8 @@ class Meta:
class MedicationLog(models.Model):
log_id = models.AutoField(primary_key=True)
user = models.ForeignKey('Users', models.DO_NOTHING, blank=True, null=True)
medication = models.ForeignKey(MedicationInfo, models.DO_NOTHING, blank=True, null=True)
medication = models.ForeignKey(MedicationInfo, models.DO_NOTHING, blank=True,
null=True)
date = models.DateField()
time = models.TimeField()
time_zone = models.CharField(max_length=5)
Expand Down
Binary file added backend/api/static/images/hai.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 3 additions & 1 deletion backend/api/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@

from django.shortcuts import render
from django.http import HttpResponse
from django.conf import settings
import os

# Create your views here.
def test_page(request):
return HttpResponse('This is a test page to verify if the django setup works')

def api_home(request):
return HttpResponse('API Landing page')
return render(request, os.path.join(settings.FRONTEND_DIR, 'api_home.html'))
Binary file modified backend/med_reminder/__pycache__/settings.cpython-310.pyc
Binary file not shown.
Binary file modified backend/med_reminder/__pycache__/urls.cpython-310.pyc
Binary file not shown.
15 changes: 12 additions & 3 deletions backend/med_reminder/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@

# Build paths inside the project like this: BASE_DIR / 'subdir'.
BASE_DIR = Path(__file__).resolve().parent.parent

FRONTEND_DIR = os.path.join(BASE_DIR, '..', 'frontend')
print(FRONTEND_DIR)

# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/5.0/howto/deployment/checklist/
Expand Down Expand Up @@ -63,7 +64,10 @@
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [],
'DIRS': [
FRONTEND_DIR,
os.path.join(FRONTEND_DIR, 'lib'),
],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
Expand Down Expand Up @@ -132,7 +136,12 @@
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/5.0/howto/static-files/

STATIC_URL = 'static/'
STATIC_URL = '/static/'

# Additional directories to find static files
STATICFILES_DIRS = [
os.path.join(BASE_DIR, 'api/static'),
]

# Default primary key field type
# https://docs.djangoproject.com/en/5.0/ref/settings/#default-auto-field
Expand Down
2 changes: 1 addition & 1 deletion backend/med_reminder/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,5 @@

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

0 comments on commit af9cc29

Please sign in to comment.