diff --git a/mypro/db.sqlite3 b/mypro/db.sqlite3
new file mode 100644
index 0000000..02b3fc9
Binary files /dev/null and b/mypro/db.sqlite3 differ
diff --git a/mypro/manage.py b/mypro/manage.py
new file mode 100755
index 0000000..9c9c323
--- /dev/null
+++ b/mypro/manage.py
@@ -0,0 +1,22 @@
+#!/usr/bin/env python
+"""Django's command-line utility for administrative tasks."""
+import os
+import sys
+
+
+def main():
+ """Run administrative tasks."""
+ os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'mypro.settings')
+ try:
+ from django.core.management import execute_from_command_line
+ except ImportError as exc:
+ raise ImportError(
+ "Couldn't import Django. Are you sure it's installed and "
+ "available on your PYTHONPATH environment variable? Did you "
+ "forget to activate a virtual environment?"
+ ) from exc
+ execute_from_command_line(sys.argv)
+
+
+if __name__ == '__main__':
+ main()
diff --git a/mypro/myapp/__init__.py b/mypro/myapp/__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/mypro/myapp/__pycache__/__init__.cpython-310.pyc b/mypro/myapp/__pycache__/__init__.cpython-310.pyc
new file mode 100644
index 0000000..103587e
Binary files /dev/null and b/mypro/myapp/__pycache__/__init__.cpython-310.pyc differ
diff --git a/mypro/myapp/__pycache__/admin.cpython-310.pyc b/mypro/myapp/__pycache__/admin.cpython-310.pyc
new file mode 100644
index 0000000..25186c2
Binary files /dev/null and b/mypro/myapp/__pycache__/admin.cpython-310.pyc differ
diff --git a/mypro/myapp/__pycache__/apps.cpython-310.pyc b/mypro/myapp/__pycache__/apps.cpython-310.pyc
new file mode 100644
index 0000000..e7ee4a4
Binary files /dev/null and b/mypro/myapp/__pycache__/apps.cpython-310.pyc differ
diff --git a/mypro/myapp/__pycache__/models.cpython-310.pyc b/mypro/myapp/__pycache__/models.cpython-310.pyc
new file mode 100644
index 0000000..fc23869
Binary files /dev/null and b/mypro/myapp/__pycache__/models.cpython-310.pyc differ
diff --git a/mypro/myapp/__pycache__/tests.cpython-310.pyc b/mypro/myapp/__pycache__/tests.cpython-310.pyc
new file mode 100644
index 0000000..3afb703
Binary files /dev/null and b/mypro/myapp/__pycache__/tests.cpython-310.pyc differ
diff --git a/mypro/myapp/__pycache__/urls.cpython-310.pyc b/mypro/myapp/__pycache__/urls.cpython-310.pyc
new file mode 100644
index 0000000..0c35df9
Binary files /dev/null and b/mypro/myapp/__pycache__/urls.cpython-310.pyc differ
diff --git a/mypro/myapp/__pycache__/views.cpython-310.pyc b/mypro/myapp/__pycache__/views.cpython-310.pyc
new file mode 100644
index 0000000..af4acdc
Binary files /dev/null and b/mypro/myapp/__pycache__/views.cpython-310.pyc differ
diff --git a/mypro/myapp/admin.py b/mypro/myapp/admin.py
new file mode 100644
index 0000000..62d6b4f
--- /dev/null
+++ b/mypro/myapp/admin.py
@@ -0,0 +1,6 @@
+from django.contrib import admin
+
+# Register your models here.
+from .models import Question
+
+admin.site.register(Question)
diff --git a/mypro/myapp/apps.py b/mypro/myapp/apps.py
new file mode 100644
index 0000000..c34fb20
--- /dev/null
+++ b/mypro/myapp/apps.py
@@ -0,0 +1,6 @@
+from django.apps import AppConfig
+
+
+class MyappConfig(AppConfig):
+ default_auto_field = 'django.db.models.BigAutoField'
+ name = 'myapp'
diff --git a/mypro/myapp/blue_page.png b/mypro/myapp/blue_page.png
new file mode 100644
index 0000000..747e23e
Binary files /dev/null and b/mypro/myapp/blue_page.png differ
diff --git a/mypro/myapp/convert.py b/mypro/myapp/convert.py
new file mode 100644
index 0000000..f5fd03c
--- /dev/null
+++ b/mypro/myapp/convert.py
@@ -0,0 +1,82 @@
+import pdfkit
+import cairosvg
+from html2image import Html2Image
+hti = Html2Image()
+
+def convert_html_file_to_pdf(html_file_path, output_file_path, type, output_pdf_file_path):
+ """
+ Convert HTML file to PDF.
+
+ Args:
+ html_file_path (str): Path to the HTML file.
+ output_file_path (str): Path to save the output PDF file.
+
+ """
+
+ if(type == "pdf"):
+ try:
+ options = {
+ 'page-size': 'A4',
+ 'margin-top': '0mm',
+ 'margin-right': '0mm',
+ 'margin-bottom': '0mm',
+ 'margin-left': '0mm',
+ }
+ print("html_file_path>>>>>>>>>>", html_file_path)
+ pdfkit.from_file(html_file_path, output_file_path, options=options)
+ print(f'PDF successfully created at: {output_file_path}')
+ except FileNotFoundError as e:
+ print(f'HTML file not found: {html_file_path}')
+ except Exception as e:
+ print(f'Error converting HTML to PDF: {e}')
+
+ elif(type == "svg"):
+ #write a code to convert html to svg
+ # try:
+ # with open(html_file_path, 'rb') as html_file:
+ # svg_data = cairosvg.svg2svg(file_obj=html_file)
+
+ # with open(output_file_path, 'wb') as svg_file:
+ # svg_file.write(svg_data)
+
+ # print(f'SVG successfully created at: {output_file_path}')
+ # except FileNotFoundError as e:
+ # print(f'HTML file not found: {html_file_path}')
+ # except Exception as e:
+ # print(f'Error converting HTML to SVG: {e}')
+ #Assuming hti.screenshot captures HTML content and saves it to an image
+ #hti.screenshot(html_file=html_file_path, save_as='temp_img.svg')
+
+ # Convert the temporary image to SVG using cairosvg
+ # cairosvg.svg2svg(url='temp_img.png', write_to=output_file_path)
+ # try:
+ # cairosvg.svg2svg(url=html_file_path, write_to=output_file_path)
+ # except Exception as e:
+ # print(f"Error converting image to SVG: {e}")
+ from weasyprint import HTML
+ HTML(filename=html_file_path).write_pdf(output_pdf_file_path)
+ from cairosvg import svg2svg
+
+ # Convert PDF to SVG using cairosvg
+ svg2svg(url=output_pdf_file_path, write_to=output_file_path)
+
+
+
+
+
+ elif(type == "img"):
+ #write a code to convert html to img
+ hti.screenshot(html_file=html_file_path,save_as='blue_page.png')
+
+
+if __name__ == "__main__":
+ type = "svg"
+ # Input HTML file path
+ html_file_path = "/home/nandeesh/Desktop/demo_django/mypro/myapp/input.html"
+ output_pdf_file_path = "/home/nandeesh/Desktop/demo_django/mypro/myapp/output.pdf"
+
+ # Output PDF file path
+ output_file_path = "/home/nandeesh/Desktop/demo_django/mypro/myapp/output.svg"
+
+ convert_html_file_to_pdf(html_file_path, output_file_path, type, output_pdf_file_path)
+
diff --git a/mypro/myapp/input.html b/mypro/myapp/input.html
new file mode 100644
index 0000000..1c3f3dd
--- /dev/null
+++ b/mypro/myapp/input.html
@@ -0,0 +1,10 @@
+
+
+
+ Sample HTML
+
+
+ Hello, World!
+ This is a sample HTML file.
+
+
diff --git a/mypro/myapp/migrations/0001_initial.py b/mypro/myapp/migrations/0001_initial.py
new file mode 100644
index 0000000..43e35b6
--- /dev/null
+++ b/mypro/myapp/migrations/0001_initial.py
@@ -0,0 +1,32 @@
+# Generated by Django 4.2.5 on 2023-09-06 06:02
+
+from django.db import migrations, models
+import django.db.models.deletion
+
+
+class Migration(migrations.Migration):
+
+ initial = True
+
+ dependencies = [
+ ]
+
+ operations = [
+ migrations.CreateModel(
+ name='Question',
+ fields=[
+ ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
+ ('question_text', models.CharField(max_length=200)),
+ ('pub_date', models.DateTimeField(verbose_name='date published')),
+ ],
+ ),
+ migrations.CreateModel(
+ name='Choice',
+ fields=[
+ ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
+ ('choice_text', models.CharField(max_length=200)),
+ ('votes', models.IntegerField(default=0)),
+ ('question', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='myapp.question')),
+ ],
+ ),
+ ]
diff --git a/mypro/myapp/migrations/__init__.py b/mypro/myapp/migrations/__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/mypro/myapp/migrations/__pycache__/0001_initial.cpython-310.pyc b/mypro/myapp/migrations/__pycache__/0001_initial.cpython-310.pyc
new file mode 100644
index 0000000..323646f
Binary files /dev/null and b/mypro/myapp/migrations/__pycache__/0001_initial.cpython-310.pyc differ
diff --git a/mypro/myapp/migrations/__pycache__/__init__.cpython-310.pyc b/mypro/myapp/migrations/__pycache__/__init__.cpython-310.pyc
new file mode 100644
index 0000000..7d57a20
Binary files /dev/null and b/mypro/myapp/migrations/__pycache__/__init__.cpython-310.pyc differ
diff --git a/mypro/myapp/models.py b/mypro/myapp/models.py
new file mode 100644
index 0000000..75521f9
--- /dev/null
+++ b/mypro/myapp/models.py
@@ -0,0 +1,27 @@
+from django.db import models
+import datetime
+from django.utils import timezone
+
+# Create your models here.
+class Question(models.Model):
+ question_text = models.CharField(max_length=200)
+ pub_date = models.DateTimeField("date published")
+
+ def __str__(self):
+ return self.question_text
+
+ def was_published_recently(self):
+ return self.pub_date >= timezone.now() - datetime.timedelta(days=1)
+
+class Choice(models.Model):
+ question = models.ForeignKey(Question, on_delete=models.CASCADE)
+ choice_text = models.CharField(max_length=200)
+ votes = models.IntegerField(default=0)
+
+ def __str__(self) :
+ return self.choice_text
+
+
+def was_published_recently(self):
+ now = timezone.now()
+ return now - datetime.timedelta(days=1) <= self.pub_date <= now
\ No newline at end of file
diff --git a/mypro/myapp/output.pdf b/mypro/myapp/output.pdf
new file mode 100644
index 0000000..7e09ab3
Binary files /dev/null and b/mypro/myapp/output.pdf differ
diff --git a/mypro/myapp/output.svg b/mypro/myapp/output.svg
new file mode 100644
index 0000000..5ce6b35
Binary files /dev/null and b/mypro/myapp/output.svg differ
diff --git a/mypro/myapp/static/myapp/images/background.png b/mypro/myapp/static/myapp/images/background.png
new file mode 100644
index 0000000..e69de29
diff --git a/mypro/myapp/static/myapp/style.css b/mypro/myapp/static/myapp/style.css
new file mode 100644
index 0000000..8f5e81e
--- /dev/null
+++ b/mypro/myapp/static/myapp/style.css
@@ -0,0 +1,7 @@
+li a {
+ color: green;
+}
+
+body {
+ background: yellow url("images/background.png") no-repeat;
+}
\ No newline at end of file
diff --git a/mypro/myapp/temp_img.png b/mypro/myapp/temp_img.png
new file mode 100644
index 0000000..747e23e
Binary files /dev/null and b/mypro/myapp/temp_img.png differ
diff --git a/mypro/myapp/templates/detail.html b/mypro/myapp/templates/detail.html
new file mode 100644
index 0000000..090d974
--- /dev/null
+++ b/mypro/myapp/templates/detail.html
@@ -0,0 +1,12 @@
+
\ No newline at end of file
diff --git a/mypro/myapp/templates/myapp/index.html b/mypro/myapp/templates/myapp/index.html
new file mode 100644
index 0000000..50687e8
--- /dev/null
+++ b/mypro/myapp/templates/myapp/index.html
@@ -0,0 +1,13 @@
+{% if latest_question_list %}
+
+{% else %}
+ No polls are available.
+{% endif %}
+
+{% load static %}
+
+
\ No newline at end of file
diff --git a/mypro/myapp/templates/myapp/results.html b/mypro/myapp/templates/myapp/results.html
new file mode 100644
index 0000000..c76de33
--- /dev/null
+++ b/mypro/myapp/templates/myapp/results.html
@@ -0,0 +1,9 @@
+{{ question.question_text }}
+
+
+{% for choice in question.choice_set.all %}
+ - {{ choice.choice_text }} -- {{ choice.votes }} vote{{ choice.votes|pluralize }}
+{% endfor %}
+
+
+Vote again?
\ No newline at end of file
diff --git a/mypro/myapp/tests.py b/mypro/myapp/tests.py
new file mode 100644
index 0000000..d18399d
--- /dev/null
+++ b/mypro/myapp/tests.py
@@ -0,0 +1,129 @@
+from django.test import TestCase
+
+# Create your tests here.
+import datetime
+
+from django.urls import reverse
+from django.utils import timezone
+
+from .models import Question
+
+
+class QuestionModelTests(TestCase):
+ def test_was_published_recently_with_future_question(self):
+ """
+ was_published_recently() returns False for questions whose pub_date
+ is in the future.
+ """
+ time = timezone.now() + datetime.timedelta(days=30)
+ future_question = Question(pub_date=time)
+ self.assertIs(future_question.was_published_recently(), False)
+
+
+def test_was_published_recently_with_old_question(self):
+ """
+ was_published_recently() returns False for questions whose pub_date
+ is older than 1 day.
+ """
+ time = timezone.now() - datetime.timedelta(days=1, seconds=1)
+ old_question = Question(pub_date=time)
+ self.assertIs(old_question.was_published_recently(), False)
+
+
+def test_was_published_recently_with_recent_question(self):
+ """
+ was_published_recently() returns True for questions whose pub_date
+ is within the last day.
+ """
+ time = timezone.now() - datetime.timedelta(hours=23, minutes=59, seconds=59)
+ recent_question = Question(pub_date=time)
+ self.assertIs(recent_question.was_published_recently(), True)
+
+def create_question(question_text, days):
+ """
+ Create a question with the given `question_text` and published the
+ given number of `days` offset to now (negative for questions published
+ in the past, positive for questions that have yet to be published).
+ """
+ time = timezone.now() + datetime.timedelta(days=days)
+ return Question.objects.create(question_text=question_text, pub_date=time)
+
+
+class QuestionIndexViewTests(TestCase):
+ def test_no_questions(self):
+ """
+ If no questions exist, an appropriate message is displayed.
+ """
+ response = self.client.get(reverse("myapp:index"))
+ self.assertEqual(response.status_code, 200)
+ self.assertContains(response, "No polls are available.")
+ self.assertQuerySetEqual(response.context["latest_question_list"], [])
+
+ def test_past_question(self):
+ """
+ Questions with a pub_date in the past are displayed on the
+ index page.
+ """
+ question = create_question(question_text="Past question.", days=-30)
+ response = self.client.get(reverse("myapp:index"))
+ self.assertQuerySetEqual(
+ response.context["latest_question_list"],
+ [question],
+ )
+
+ def test_future_question(self):
+ """
+ Questions with a pub_date in the future aren't displayed on
+ the index page.
+ """
+ create_question(question_text="Future question.", days=30)
+ response = self.client.get(reverse("myapp:index"))
+ self.assertContains(response, "No polls are available.")
+ self.assertQuerySetEqual(response.context["latest_question_list"], [])
+
+ def test_future_question_and_past_question(self):
+ """
+ Even if both past and future questions exist, only past questions
+ are displayed.
+ """
+ question = create_question(question_text="Past question.", days=-30)
+ create_question(question_text="Future question.", days=30)
+ response = self.client.get(reverse("myapp:index"))
+ self.assertQuerySetEqual(
+ response.context["latest_question_list"],
+ [question],
+ )
+
+ def test_two_past_questions(self):
+ """
+ The questions index page may display multiple questions.
+ """
+ question1 = create_question(question_text="Past question 1.", days=-30)
+ question2 = create_question(question_text="Past question 2.", days=-5)
+ response = self.client.get(reverse("myapp:index"))
+ self.assertQuerySetEqual(
+ response.context["latest_question_list"],
+ [question2, question1],
+ )
+
+
+class QuestionDetailViewTests(TestCase):
+ def test_future_question(self):
+ """
+ The detail view of a question with a pub_date in the future
+ returns a 404 not found.
+ """
+ future_question = create_question(question_text="Future question.", days=5)
+ url = reverse("polls:detail", args=(future_question.id,))
+ response = self.client.get(url)
+ self.assertEqual(response.status_code, 404)
+
+ def test_past_question(self):
+ """
+ The detail view of a question with a pub_date in the past
+ displays the question's text.
+ """
+ past_question = create_question(question_text="Past Question.", days=-5)
+ url = reverse("polls:detail", args=(past_question.id,))
+ response = self.client.get(url)
+ self.assertContains(response, past_question.question_text)
\ No newline at end of file
diff --git a/mypro/myapp/text.py b/mypro/myapp/text.py
new file mode 100644
index 0000000..c84c6be
--- /dev/null
+++ b/mypro/myapp/text.py
@@ -0,0 +1,83 @@
+import pdfkit
+import cairosvg
+from html2image import Html2Image
+hti = Html2Image()
+
+def convert_html_file_to_pdf(html_file_path, output_file_path, type, output_pdf_file_path):
+ """
+ Convert HTML file to PDF.
+
+ Args:
+ html_file_path (str): Path to the HTML file.
+ output_file_path (str): Path to save the output PDF file.
+
+ """
+
+ if(type == "pdf"):
+ try:
+ options = {
+ 'page-size': 'A4',
+ 'margin-top': '0mm',
+ 'margin-right': '0mm',
+ 'margin-bottom': '0mm',
+ 'margin-left': '0mm',
+ }
+ print("html_file_path>>>>>>>>>>", html_file_path)
+ pdfkit.from_file(html_file_path, output_file_path, options=options)
+ print(f'PDF successfully created at: {output_file_path}')
+ except FileNotFoundError as e:
+ print(f'HTML file not found: {html_file_path}')
+ except Exception as e:
+ print(f'Error converting HTML to PDF: {e}')
+
+ elif(type == "svg"):
+ #write a code to convert html to svg
+ # try:
+ # with open(html_file_path, 'rb') as html_file:
+ # svg_data = cairosvg.svg2svg(file_obj=html_file)
+
+ # with open(output_file_path, 'wb') as svg_file:
+ # svg_file.write(svg_data)
+
+ # print(f'SVG successfully created at: {output_file_path}')
+ # except FileNotFoundError as e:
+ # print(f'HTML file not found: {html_file_path}')
+ # except Exception as e:
+ # print(f'Error converting HTML to SVG: {e}')
+ #Assuming hti.screenshot captures HTML content and saves it to an image
+ #hti.screenshot(html_file=html_file_path, save_as='temp_img.svg')
+
+ # Convert the temporary image to SVG using cairosvg
+ # cairosvg.svg2svg(url='temp_img.png', write_to=output_file_path)
+ # try:
+ # cairosvg.svg2svg(url=html_file_path, write_to=output_file_path)
+ # except Exception as e:
+ # print(f"Error converting image to SVG: {e}")
+ from weasyprint import HTML
+ HTML(filename=html_file_path).write_pdf(output_pdf_file_path)
+ from cairosvg import svg2svg
+
+ # Convert PDF to SVG using cairosvg
+ svg2svg(url=output_pdf_file_path, write_to=output_file_path)
+
+
+
+
+
+ elif(type == "img"):
+ #write a code to convert html to img
+ hti.screenshot(html_file=html_file_path,save_as='blue_page.png')
+ print("helloo")
+
+
+if __name__ == "__main__":
+ type = "svg"
+ # Input HTML file path
+ html_file_path = "/home/nandeesh/Desktop/demo_django/mypro/myapp/input.html"
+ output_pdf_file_path = "/home/nandeesh/Desktop/demo_django/mypro/myapp/output.pdf"
+
+ # Output PDF file path
+ output_file_path = "/home/nandeesh/Desktop/demo_django/mypro/myapp/output.svg"
+
+ convert_html_file_to_pdf(html_file_path, output_file_path, type, output_pdf_file_path)
+
diff --git a/mypro/myapp/urls.py b/mypro/myapp/urls.py
new file mode 100644
index 0000000..0934007
--- /dev/null
+++ b/mypro/myapp/urls.py
@@ -0,0 +1,20 @@
+from django.urls import path
+from . import views
+
+app_name = "myapp"
+urlpatterns=[
+ #ex:/myapp/ind/
+ # path("ind/",views.index,name="name"),
+
+ # # ex: /myapp/5/
+ # path("/detail/", views.detail, name="detail"),
+ # # ex: /myapp/5/results/
+ # path("/results/", views.results, name="results"),
+ # # ex: /myapp/5/vote/
+ # path("/vote/", views.vote, name="vote"),
+
+ path("",views.IndexView.as_view(),name="index"),
+ path("/",views.DetailView.as_view(),name="detail"),
+ path("/results/",views.ResultView.as_view(),name="results"),
+ path("/vote/",views.vote,name="vote"),
+]
\ No newline at end of file
diff --git a/mypro/myapp/views.py b/mypro/myapp/views.py
new file mode 100644
index 0000000..3935270
--- /dev/null
+++ b/mypro/myapp/views.py
@@ -0,0 +1,73 @@
+from typing import Any
+from django.db import models
+from django.shortcuts import render,get_object_or_404
+from django.http import HttpResponse,HttpResponseRedirect
+from .models import Question,Choice
+from django.template import loader
+from django.http import Http404
+from django.urls import reverse
+from django.views import generic
+from django.utils import timezone
+
+
+# Create your views here.
+# def index(request):
+# latest_question_list=Question.objects.order_by("-pub_date")[:5]
+# # template=loader.get_template("myapp/index.html")
+# # output=",".join([q.question_text for q in latest_question_list])
+# context={"latest_question_list":latest_question_list}
+# # return HttpResponse(template.render(context,request))
+# return render(request,"myapp/index.html",context)
+
+# def detail(request, question_id):
+# # try:
+# # question=Question.objects.get(pk=question_id)
+# # except Question.DoesNotExist:
+# # raise Http404("Question not found")
+
+# # # return HttpResponse("You're looking at question %s." % question_id)
+# # return render(request,'myapp/detail.html',{"question":question})
+# question = get_object_or_404(Question, pk=question_id)
+# return render(request, "myapp/detail.html", {"question": question})
+
+
+# def results(request, question_id):
+# # response = "You're looking at the results of question %s."
+# # return HttpResponse(response % question_id)
+# question=get_object_or_404(Question,pk=question_id)
+# return render(request,"myapp/results.html",{"question":question})
+
+
+class IndexView(generic.ListView):
+ template_name="myapp/index.html"
+ context_object_name="latest_question_list"
+
+ def get_queryset(self):
+ return Question.objects.filter(pub_date__lte=timezone.now()).order_by("-pub_date")[:5]
+
+class DetailView(generic.DetailView):
+ model=Question
+ template_name="myapp/detail.html"
+
+ def get_queryset(self):
+ return Question.objects.filter(pub_date__lte=timezone.now())
+
+class ResultView(generic.DetailView):
+ model=Question
+ template_name="myapp/results.html"
+
+def vote(request, question_id):
+
+ question=get_object_or_404(Question,pk=question_id)
+ try:
+ selected_choice=question.choice_set.get(pk=request.POST["choice"])
+ except(KeyError,Choice.DoesNotExist):
+ return render(request,"myapp/detail.html",{"question":question,"error_message":"you didnt select a choice"})
+
+ else:
+ selected_choice.votes += 1
+ selected_choice.save()
+ # Always return an HttpResponseRedirect after successfully dealing
+ # with POST data. This prevents data from being posted twice if a
+ # user hits the Back button.
+ return HttpResponseRedirect(reverse("myapp:results", args=(question.id,)))
\ No newline at end of file
diff --git a/mypro/mypro/__init__.py b/mypro/mypro/__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/mypro/mypro/__pycache__/__init__.cpython-310.pyc b/mypro/mypro/__pycache__/__init__.cpython-310.pyc
new file mode 100644
index 0000000..f52c8ef
Binary files /dev/null and b/mypro/mypro/__pycache__/__init__.cpython-310.pyc differ
diff --git a/mypro/mypro/__pycache__/settings.cpython-310.pyc b/mypro/mypro/__pycache__/settings.cpython-310.pyc
new file mode 100644
index 0000000..54fe276
Binary files /dev/null and b/mypro/mypro/__pycache__/settings.cpython-310.pyc differ
diff --git a/mypro/mypro/__pycache__/urls.cpython-310.pyc b/mypro/mypro/__pycache__/urls.cpython-310.pyc
new file mode 100644
index 0000000..51855c7
Binary files /dev/null and b/mypro/mypro/__pycache__/urls.cpython-310.pyc differ
diff --git a/mypro/mypro/__pycache__/wsgi.cpython-310.pyc b/mypro/mypro/__pycache__/wsgi.cpython-310.pyc
new file mode 100644
index 0000000..dafa841
Binary files /dev/null and b/mypro/mypro/__pycache__/wsgi.cpython-310.pyc differ
diff --git a/mypro/mypro/asgi.py b/mypro/mypro/asgi.py
new file mode 100644
index 0000000..c5d2d01
--- /dev/null
+++ b/mypro/mypro/asgi.py
@@ -0,0 +1,16 @@
+"""
+ASGI config for mypro project.
+
+It exposes the ASGI callable as a module-level variable named ``application``.
+
+For more information on this file, see
+https://docs.djangoproject.com/en/4.2/howto/deployment/asgi/
+"""
+
+import os
+
+from django.core.asgi import get_asgi_application
+
+os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'mypro.settings')
+
+application = get_asgi_application()
diff --git a/mypro/mypro/settings.py b/mypro/mypro/settings.py
new file mode 100644
index 0000000..eee0333
--- /dev/null
+++ b/mypro/mypro/settings.py
@@ -0,0 +1,130 @@
+"""
+Django settings for mypro project.
+
+Generated by 'django-admin startproject' using Django 4.2.5.
+
+For more information on this file, see
+https://docs.djangoproject.com/en/4.2/topics/settings/
+
+For the full list of settings and their values, see
+https://docs.djangoproject.com/en/4.2/ref/settings/
+"""
+
+from pathlib import Path
+import os
+
+# Build paths inside the project like this: BASE_DIR / 'subdir'.
+BASE_DIR = Path(__file__).resolve().parent.parent
+
+
+# Quick-start development settings - unsuitable for production
+# See https://docs.djangoproject.com/en/4.2/howto/deployment/checklist/
+
+# SECURITY WARNING: keep the secret key used in production secret!
+SECRET_KEY = 'django-insecure-u-=vnp_qdmbwv$lz4mhu%94_gk%t3fq=i+!2fk#!ycc^gbxl0r'
+
+# SECURITY WARNING: don't run with debug turned on in production!
+DEBUG = True
+
+ALLOWED_HOSTS = []
+
+
+# Application definition
+
+INSTALLED_APPS = [
+ 'myapp.apps.MyappConfig',
+ 'django.contrib.admin',
+ 'django.contrib.auth',
+ 'django.contrib.contenttypes',
+ 'django.contrib.sessions',
+ 'django.contrib.messages',
+ 'django.contrib.staticfiles'
+
+
+]
+
+MIDDLEWARE = [
+ 'django.middleware.security.SecurityMiddleware',
+ 'django.contrib.sessions.middleware.SessionMiddleware',
+ 'django.middleware.common.CommonMiddleware',
+ 'django.middleware.csrf.CsrfViewMiddleware',
+ 'django.contrib.auth.middleware.AuthenticationMiddleware',
+ 'django.contrib.messages.middleware.MessageMiddleware',
+ 'django.middleware.clickjacking.XFrameOptionsMiddleware',
+]
+
+ROOT_URLCONF = 'mypro.urls'
+
+TEMPLATES = [
+ {
+ 'BACKEND': 'django.template.backends.django.DjangoTemplates',
+ 'DIRS': [],
+ 'APP_DIRS': True,
+ 'OPTIONS': {
+ 'context_processors': [
+ 'django.template.context_processors.debug',
+ 'django.template.context_processors.request',
+ 'django.contrib.auth.context_processors.auth',
+ 'django.contrib.messages.context_processors.messages',
+ ],
+ },
+ },
+]
+
+WSGI_APPLICATION = 'mypro.wsgi.application'
+
+
+# Database
+# https://docs.djangoproject.com/en/4.2/ref/settings/#databases
+
+DATABASES = {
+ 'default': {
+ 'ENGINE': 'django.db.backends.postgresql',
+ 'NAME': 'mydb',
+ 'USER':'postgres',
+ 'PASSWORD':'postgres',
+ 'HOST':'localhost'
+ }
+}
+
+
+# Password validation
+# https://docs.djangoproject.com/en/4.2/ref/settings/#auth-password-validators
+
+AUTH_PASSWORD_VALIDATORS = [
+ {
+ 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
+ },
+ {
+ 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
+ },
+ {
+ 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
+ },
+ {
+ 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
+ },
+]
+
+
+# Internationalization
+# https://docs.djangoproject.com/en/4.2/topics/i18n/
+
+LANGUAGE_CODE = 'en-us'
+
+TIME_ZONE = 'UTC'
+
+USE_I18N = True
+
+USE_TZ = True
+
+
+# Static files (CSS, JavaScript, Images)
+# https://docs.djangoproject.com/en/4.2/howto/static-files/
+
+STATIC_URL = 'static/'
+
+# Default primary key field type
+# https://docs.djangoproject.com/en/4.2/ref/settings/#default-auto-field
+
+DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
diff --git a/mypro/mypro/urls.py b/mypro/mypro/urls.py
new file mode 100644
index 0000000..1df0faa
--- /dev/null
+++ b/mypro/mypro/urls.py
@@ -0,0 +1,23 @@
+"""
+URL configuration for mypro project.
+
+The `urlpatterns` list routes URLs to views. For more information please see:
+ https://docs.djangoproject.com/en/4.2/topics/http/urls/
+Examples:
+Function views
+ 1. Add an import: from my_app import views
+ 2. Add a URL to urlpatterns: path('', views.home, name='home')
+Class-based views
+ 1. Add an import: from other_app.views import Home
+ 2. Add a URL to urlpatterns: path('', Home.as_view(), name='home')
+Including another URLconf
+ 1. Import the include() function: from django.urls import include, path
+ 2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
+"""
+from django.contrib import admin
+from django.urls import path,include
+
+urlpatterns = [
+ path('admin/', admin.site.urls),
+ path("myapp/",include("myapp.urls"))
+]
diff --git a/mypro/mypro/wsgi.py b/mypro/mypro/wsgi.py
new file mode 100644
index 0000000..32158f4
--- /dev/null
+++ b/mypro/mypro/wsgi.py
@@ -0,0 +1,16 @@
+"""
+WSGI config for mypro project.
+
+It exposes the WSGI callable as a module-level variable named ``application``.
+
+For more information on this file, see
+https://docs.djangoproject.com/en/4.2/howto/deployment/wsgi/
+"""
+
+import os
+
+from django.core.wsgi import get_wsgi_application
+
+os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'mypro.settings')
+
+application = get_wsgi_application()
diff --git a/sourcecode/demosonar.py b/sourcecode/demosonar.py
index 08fadd1..0b60351 100644
--- a/sourcecode/demosonar.py
+++ b/sourcecode/demosonar.py
@@ -1,81 +1,31 @@
-import pdfkit
-import cairosvg
-from html2image import Html2Image
-hti = Html2Image()
-
-def convert_html_file_to_pdf(html_file_path, output_file_path, type, output_pdf_file_path):
- """
- Convert HTML file to PDF.
-
- Args:
- html_file_path (str): Path to the HTML file.
- output_file_path (str): Path to save the output PDF file.
-
- """
-
- if(type == "pdf"):
- try:
- options = {
- 'page-size': 'A4',
- 'margin-top': '0mm',
- 'margin-right': '0mm',
- 'margin-bottom': '0mm',
- 'margin-left': '0mm',
- }
- print("html_file_path>>>>>>>>>>", html_file_path)
- pdfkit.from_file(html_file_path, output_file_path, options=options)
- print(f'PDF successfully created at: {output_file_path}')
- except FileNotFoundError as e:
- print(f'HTML file not found: {html_file_path}')
- except Exception as e:
- print(f'Error converting HTML to PDF: {e}')
-
- elif(type == "svg"):
- #write a code to convert html to svg
- # try:
- # with open(html_file_path, 'rb') as html_file:
- # svg_data = cairosvg.svg2svg(file_obj=html_file)
-
- # with open(output_file_path, 'wb') as svg_file:
- # svg_file.write(svg_data)
-
- # print(f'SVG successfully created at: {output_file_path}')
- # except FileNotFoundError as e:
- # print(f'HTML file not found: {html_file_path}')
- # except Exception as e:
- # print(f'Error converting HTML to SVG: {e}')
- #Assuming hti.screenshot captures HTML content and saves it to an image
- #hti.screenshot(html_file=html_file_path, save_as='temp_img.svg')
-
- # Convert the temporary image to SVG using cairosvg
- # cairosvg.svg2svg(url='temp_img.png', write_to=output_file_path)
- # try:
- # cairosvg.svg2svg(url=html_file_path, write_to=output_file_path)
- # except Exception as e:
- # print(f"Error converting image to SVG: {e}")
- from weasyprint import HTML
- HTML(filename=html_file_path).write_pdf(output_pdf_file_path)
- from cairosvg import svg2svg
-
- # Convert PDF to SVG using cairosvg
- svg2svg(url=output_pdf_file_path, write_to=output_file_path)
-
-
-
-
-
- elif(type == "img"):
- #write a code to convert html to img
- hti.screenshot(html_file=html_file_path,save_as='blue_page.png')
-
-
-if __name__ == "__main__":
- type = "svg"
- # Input HTML file path
- html_file_path = "/home/nandeesh/Desktop/demo_django/mypro/myapp/input.html"
- output_pdf_file_path = "/home/nandeesh/Desktop/demo_django/mypro/myapp/output.pdf"
-
- # Output PDF file path
- output_file_path = "/home/nandeesh/Desktop/demo_django/mypro/myapp/output.svg"
-
- convert_html_file_to_pdf(html_file_path, output_file_path, type, output_pdf_file_path)
+import os
+import requests
+import sys
+
+TOKEN= str(sys.argv[1])
+OWNER= str(sys.argv[2])
+REPO= str(sys.argv[3])
+workflow_name= str(sys.argv[4])
+parameter1= str(sys.argv[5])
+parameter2 = str(sys.argv[6])
+
+print( "the toke value is")
+def trigger_workflow(workflow_name,parameter1,parameter2):
+
+ headers = {
+ "Accept": "application/vnd.github.v3+json",
+ "Authorization": f"token {TOKEN}",
+ }
+
+ data = {
+ "event_type": workflow_name,
+ "client_payload": {
+ 'parameter1': parameter1,
+ 'parameter2': parameter2
+ }
+ }
+
+ responsevalue=requests.post(f"https://api.github.com/repos/{OWNER}/{REPO}/dispatches",json=data,headers=headers)
+ print(responsevalue.content)
+
+trigger_workflow(workflow_name,parameter1,parameter2)
\ No newline at end of file