This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
version: "3.9" | |
services: | |
core: | |
build: doccCore | |
ports: | |
- "8000:8000" | |
command: python manage.py runserver 0.0.0.0:8000 | |
volumes: | |
- ./doccCore:/doccCore | |
web: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Core Django App (File number 1) | |
FROM python:3.10.4-slim-bullseye | |
ENV PIP_DISABLE_PIP_VERSION_CHECK 1 | |
ENV PYTHONDONTWRITEBYTECODE 1 | |
ENV PYTHONUNBUFFERED 1 | |
WORKDIR /docsCore | |
COPY ./requirements.txt . |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import streamlit as st | |
import requests | |
from requests.auth import HTTPBasicAuth | |
import pandas as pd | |
import streamlit.components.v1 as components | |
from pyvis.network import Network | |
import json | |
import matplotlib.pyplot as plt | |
from wordcloud import WordCloud | |
import spacy |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.urls import path | |
from . import views | |
urlpatterns = [ | |
path('signupaccount/', views.signupaccount, name='signupaccount'), | |
path('logout/', views.logoutaccount, name='logoutaccount'), | |
path('login/', views.loginaccount, name='loginaccount'), | |
path(f'activate/(?P<uidb64>[0-9A-Za-z_\-]+)/(?P<token>[0-9A-Za-z]{1,13}-[0-9A-Za-z]{1,20})/', views.activate, name='activate'), | |
] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def logoutaccount(request): | |
logout(request) | |
return redirect('home') | |
def loginaccount(request): | |
if request.method == 'GET': | |
return render(request, 'loginaccount.html', | |
{'form':AuthenticationForm}) | |
else: | |
user = authenticate(request, username=request.POST['username'], |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def activate(request, uidb64, token): | |
User = get_user_model() | |
try: | |
uid = force_str(urlsafe_base64_decode(uidb64)) | |
user = User.objects.get(pk=uid) | |
except(TypeError, ValueError, OverflowError, User.DoesNotExist): | |
user = None | |
if user is not None and account_activation_token.check_token(user, token): | |
user.is_active = True | |
user.save() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{% autoescape off %} | |
Hi {{ user.username }}, | |
Please click on the link to confirm your registration, | |
http://{{ domain }}{% url 'activate' uidb64=uid token=token %} | |
{% endautoescape %} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.contrib.sites.shortcuts import get_current_site | |
from django.template.loader import render_to_string | |
from django.utils.http import urlsafe_base64_encode, urlsafe_base64_decode | |
from django.utils.encoding import force_bytes, force_str | |
from .token import account_activation_token | |
def signupaccount(request): | |
if request.method == 'POST': | |
form = UserCreateForm(request.POST) | |
if form.is_valid(): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django import forms | |
from django.contrib.auth.forms import UserCreationForm | |
from django.contrib.auth.models import User | |
class UserCreateForm(UserCreationForm): | |
email = forms.EmailField(max_length=200, help_text='Required') | |
class Meta: | |
model = User | |
fields = ['username', 'email', 'password1', 'password2'] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class TokenGenerator(PasswordResetTokenGenerator): | |
def _make_hash_value(self, user, timestamp): | |
return ( | |
six.text_type(user.pk) + six.text_type(timestamp) + | |
six.text_type(user.is_active) | |
) | |
account_activation_token = TokenGenerator() |