Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -490,170 +490,8 @@
|
|
490 |
|
491 |
# if __name__ == "__main__":
|
492 |
# app.run(host='0.0.0.0', port=7860)
|
493 |
-
# from http.server import HTTPServer, SimpleHTTPRequestHandler
|
494 |
-
# from pyngrok import ngrok
|
495 |
-
# import os
|
496 |
-
# from mistralai.client import MistralClient
|
497 |
-
# from mistralai.models.chat_completion import ChatMessage
|
498 |
-
# import json
|
499 |
-
|
500 |
-
# # Mistral AI setup
|
501 |
-
# api_key = os.getenv("MISTRAL_API_KEY")
|
502 |
-
# if not api_key:
|
503 |
-
# raise ValueError("MISTRAL_API_KEY environment variable not set")
|
504 |
-
|
505 |
-
# model = "mistral-tiny"
|
506 |
-
# client = MistralClient(api_key=api_key)
|
507 |
-
|
508 |
-
# def generate_goals(input_var):
|
509 |
-
# messages = [
|
510 |
-
# ChatMessage(role="user", content=f"Generate 5 specific, industry relevant goals for {input_var} using Python and Pandas in exam data analysis. Each goal should include a brief name and a one-sentence description of the task or skill.")
|
511 |
-
# ]
|
512 |
-
# try:
|
513 |
-
# response = client.chat(model=model, messages=messages)
|
514 |
-
# return response.choices[0].message.content
|
515 |
-
# except Exception as e:
|
516 |
-
# return f"An error occurred: {str(e)}"
|
517 |
-
|
518 |
-
# html_content = """
|
519 |
-
# <!DOCTYPE html>
|
520 |
-
# <html lang="en">
|
521 |
-
# <head>
|
522 |
-
# <meta charset="UTF-8">
|
523 |
-
# <meta name="viewport" content="width=device-width, initial-scale=1.0">
|
524 |
-
# <title>Exam Data Analysis Goals Generator</title>
|
525 |
-
# <script src="https://d3js.org/d3.v7.min.js"></script>
|
526 |
-
# <style>
|
527 |
-
# #visualization { width: 100%; height: 600px; border: 1px solid #ccc; }
|
528 |
-
# #generatedGoals { margin-top: 20px; padding: 10px; border: 1px solid #ccc; }
|
529 |
-
# </style>
|
530 |
-
# </head>
|
531 |
-
# <body>
|
532 |
-
# <h1>Exam Data Analysis Goals Generator</h1>
|
533 |
-
# <div id="visualization"></div>
|
534 |
-
# <div id="generatedGoals"></div>
|
535 |
-
# <script>
|
536 |
-
# const width = 1200;
|
537 |
-
# const height = 800;
|
538 |
-
# const goals = [
|
539 |
-
# { id: 1, x: 100, y: 400, name: "Automate Data Import", description: "Develop scripts to automate exam data extraction from various sources (CSV, Excel, databases) using Pandas read_* functions." },
|
540 |
-
# { id: 2, x: 200, y: 300, name: "Data Cleaning", description: "Implement robust data cleaning processes to handle missing values, outliers, and inconsistencies in exam data using Pandas methods like dropna(), fillna(), and apply()." },
|
541 |
-
# { id: 3, x: 300, y: 200, name: "Data Transformation", description: "Utilize Pandas for complex data transformations such as pivoting exam results, melting question-wise scores, and creating derived features for analysis." },
|
542 |
-
# { id: 4, x: 400, y: 300, name: "Statistical Analysis", description: "Develop functions to automate statistical analysis of exam results, including descriptive statistics, hypothesis testing, and correlation analysis using Pandas and SciPy." },
|
543 |
-
# { id: 5, x: 500, y: 400, name: "Performance Metrics", description: "Create custom functions to calculate industry-standard exam performance metrics like item difficulty, discrimination index, and reliability coefficients using Pandas operations." },
|
544 |
-
# // Add more goals here...
|
545 |
-
# ];
|
546 |
-
# const connections = [
|
547 |
-
# { source: 1, target: 2 },
|
548 |
-
# { source: 2, target: 3 },
|
549 |
-
# { source: 3, target: 4 },
|
550 |
-
# { source: 4, target: 5 },
|
551 |
-
# // Add more connections here...
|
552 |
-
# ];
|
553 |
-
# const svg = d3.select("#visualization")
|
554 |
-
# .append("svg")
|
555 |
-
# .attr("width", width)
|
556 |
-
# .attr("height", height);
|
557 |
-
# const simulation = d3.forceSimulation(goals)
|
558 |
-
# .force("link", d3.forceLink(connections).id(d => d.id))
|
559 |
-
# .force("charge", d3.forceManyBody().strength(-400))
|
560 |
-
# .force("center", d3.forceCenter(width / 2, height / 2));
|
561 |
-
# const link = svg.append("g")
|
562 |
-
# .selectAll("line")
|
563 |
-
# .data(connections)
|
564 |
-
# .enter().append("line")
|
565 |
-
# .attr("stroke", "#999")
|
566 |
-
# .attr("stroke-opacity", 0.6);
|
567 |
-
# const node = svg.append("g")
|
568 |
-
# .selectAll("circle")
|
569 |
-
# .data(goals)
|
570 |
-
# .enter().append("circle")
|
571 |
-
# .attr("r", 10)
|
572 |
-
# .attr("fill", d => d.color || "#69b3a2")
|
573 |
-
# .call(d3.drag()
|
574 |
-
# .on("start", dragstarted)
|
575 |
-
# .on("drag", dragged)
|
576 |
-
# .on("end", dragended));
|
577 |
-
# const text = svg.append("g")
|
578 |
-
# .selectAll("text")
|
579 |
-
# .data(goals)
|
580 |
-
# .enter().append("text")
|
581 |
-
# .text(d => d.name)
|
582 |
-
# .attr("font-size", "12px")
|
583 |
-
# .attr("dx", 12)
|
584 |
-
# .attr("dy", 4);
|
585 |
-
# node.on("click", async function(event, d) {
|
586 |
-
# const response = await fetch('/generate_goals', {
|
587 |
-
# method: 'POST',
|
588 |
-
# headers: { 'Content-Type': 'application/json' },
|
589 |
-
# body: JSON.stringify({ input_var: d.name })
|
590 |
-
# });
|
591 |
-
# const data = await response.json();
|
592 |
-
# document.getElementById("generatedGoals").innerHTML = `<h2>Generated Goals for ${d.name}</h2><pre>${data.goals}</pre>`;
|
593 |
-
# });
|
594 |
-
# simulation.on("tick", () => {
|
595 |
-
# link
|
596 |
-
# .attr("x1", d => d.source.x)
|
597 |
-
# .attr("y1", d => d.source.y)
|
598 |
-
# .attr("x2", d => d.target.x)
|
599 |
-
# .attr("y2", d => d.target.y);
|
600 |
-
# node
|
601 |
-
# .attr("cx", d => d.x)
|
602 |
-
# .attr("cy", d => d.y);
|
603 |
-
# text
|
604 |
-
# .attr("x", d => d.x)
|
605 |
-
# .attr("y", d => d.y);
|
606 |
-
# });
|
607 |
-
# function dragstarted(event) {
|
608 |
-
# if (!event.active) simulation.alphaTarget(0.3).restart();
|
609 |
-
# event.subject.fx = event.subject.x;
|
610 |
-
# event.subject.fy = event.subject.y;
|
611 |
-
# }
|
612 |
-
# function dragged(event) {
|
613 |
-
# event.subject.fx = event.x;
|
614 |
-
# event.subject.fy = event.y;
|
615 |
-
# }
|
616 |
-
# function dragended(event) {
|
617 |
-
# if (!event.active) simulation.alphaTarget(0);
|
618 |
-
# event.subject.fx = null;
|
619 |
-
# event.subject.fy = null;
|
620 |
-
# }
|
621 |
-
# </script>
|
622 |
-
# </body>
|
623 |
-
# </html>
|
624 |
-
# """
|
625 |
-
|
626 |
-
# class MyHandler(SimpleHTTPRequestHandler):
|
627 |
-
# def do_GET(self):
|
628 |
-
# self.send_response(200)
|
629 |
-
# self.send_header('Content-type', 'text/html')
|
630 |
-
# self.end_headers()
|
631 |
-
# self.wfile.write(html_content.encode())
|
632 |
-
|
633 |
-
# def do_POST(self):
|
634 |
-
# if self.path == '/generate_goals':
|
635 |
-
# content_length = int(self.headers['Content-Length'])
|
636 |
-
# post_data = self.rfile.read(content_length)
|
637 |
-
# data = json.loads(post_data.decode('utf-8'))
|
638 |
-
# input_var = data['input_var']
|
639 |
-
# goals = generate_goals(input_var)
|
640 |
-
|
641 |
-
# self.send_response(200)
|
642 |
-
# self.send_header('Content-type', 'application/json')
|
643 |
-
# self.end_headers()
|
644 |
-
# self.wfile.write(json.dumps({'goals': goals}).encode())
|
645 |
-
# else:
|
646 |
-
# self.send_error(404)
|
647 |
-
|
648 |
-
# if __name__ == '__main__':
|
649 |
-
# port = 7860
|
650 |
-
# server = HTTPServer(('', port), MyHandler)
|
651 |
-
# public_url = ngrok.connect(port).public_url
|
652 |
-
# print(f" * ngrok tunnel \"{public_url}\" -> \"http://127.0.0.1:{port}\"")
|
653 |
-
# server.serve_forever()
|
654 |
-
|
655 |
-
# here
|
656 |
from http.server import HTTPServer, SimpleHTTPRequestHandler
|
|
|
657 |
import os
|
658 |
from mistralai.client import MistralClient
|
659 |
from mistralai.models.chat_completion import ChatMessage
|
@@ -794,34 +632,196 @@ class MyHandler(SimpleHTTPRequestHandler):
|
|
794 |
|
795 |
def do_POST(self):
|
796 |
if self.path == '/generate_goals':
|
797 |
-
|
798 |
-
|
799 |
-
|
800 |
-
|
801 |
-
|
802 |
-
|
803 |
-
|
804 |
-
|
805 |
-
|
806 |
-
|
807 |
-
self.send_header('Content-Length', str(len(response)))
|
808 |
-
self.end_headers()
|
809 |
-
self.wfile.write(response)
|
810 |
-
except Exception as e:
|
811 |
-
logging.error(f"Error handling POST request: {str(e)}")
|
812 |
-
self.send_error(500, f"Internal server error: {str(e)}")
|
813 |
else:
|
814 |
self.send_error(404)
|
815 |
|
816 |
-
def run_server(port):
|
817 |
-
try:
|
818 |
-
server = ThreadingHTTPServer(('0.0.0.0', port), MyHandler)
|
819 |
-
print(f"Server running on port {port}")
|
820 |
-
server.serve_forever()
|
821 |
-
except Exception as e:
|
822 |
-
logging.error(f"Error running server: {str(e)}")
|
823 |
-
traceback.print_exc()
|
824 |
-
|
825 |
if __name__ == '__main__':
|
826 |
-
port =
|
827 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
490 |
|
491 |
# if __name__ == "__main__":
|
492 |
# app.run(host='0.0.0.0', port=7860)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
493 |
from http.server import HTTPServer, SimpleHTTPRequestHandler
|
494 |
+
from pyngrok import ngrok
|
495 |
import os
|
496 |
from mistralai.client import MistralClient
|
497 |
from mistralai.models.chat_completion import ChatMessage
|
|
|
632 |
|
633 |
def do_POST(self):
|
634 |
if self.path == '/generate_goals':
|
635 |
+
content_length = int(self.headers['Content-Length'])
|
636 |
+
post_data = self.rfile.read(content_length)
|
637 |
+
data = json.loads(post_data.decode('utf-8'))
|
638 |
+
input_var = data['input_var']
|
639 |
+
goals = generate_goals(input_var)
|
640 |
+
|
641 |
+
self.send_response(200)
|
642 |
+
self.send_header('Content-type', 'application/json')
|
643 |
+
self.end_headers()
|
644 |
+
self.wfile.write(json.dumps({'goals': goals}).encode())
|
|
|
|
|
|
|
|
|
|
|
|
|
645 |
else:
|
646 |
self.send_error(404)
|
647 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
648 |
if __name__ == '__main__':
|
649 |
+
port = 7860
|
650 |
+
server = HTTPServer(('', port), MyHandler)
|
651 |
+
public_url = ngrok.connect(port).public_url
|
652 |
+
print(f" * ngrok tunnel \"{public_url}\" -> \"http://127.0.0.1:{port}\"")
|
653 |
+
server.serve_forever()
|
654 |
+
|
655 |
+
# here
|
656 |
+
# from http.server import HTTPServer, SimpleHTTPRequestHandler
|
657 |
+
# import os
|
658 |
+
# from mistralai.client import MistralClient
|
659 |
+
# from mistralai.models.chat_completion import ChatMessage
|
660 |
+
# import json
|
661 |
+
|
662 |
+
# # Mistral AI setup
|
663 |
+
# api_key = os.getenv("MISTRAL_API_KEY")
|
664 |
+
# if not api_key:
|
665 |
+
# raise ValueError("MISTRAL_API_KEY environment variable not set")
|
666 |
+
|
667 |
+
# model = "mistral-tiny"
|
668 |
+
# client = MistralClient(api_key=api_key)
|
669 |
+
|
670 |
+
# def generate_goals(input_var):
|
671 |
+
# messages = [
|
672 |
+
# ChatMessage(role="user", content=f"Generate 5 specific, industry relevant goals for {input_var} using Python and Pandas in exam data analysis. Each goal should include a brief name and a one-sentence description of the task or skill.")
|
673 |
+
# ]
|
674 |
+
# try:
|
675 |
+
# response = client.chat(model=model, messages=messages)
|
676 |
+
# return response.choices[0].message.content
|
677 |
+
# except Exception as e:
|
678 |
+
# return f"An error occurred: {str(e)}"
|
679 |
+
|
680 |
+
# html_content = """
|
681 |
+
# <!DOCTYPE html>
|
682 |
+
# <html lang="en">
|
683 |
+
# <head>
|
684 |
+
# <meta charset="UTF-8">
|
685 |
+
# <meta name="viewport" content="width=device-width, initial-scale=1.0">
|
686 |
+
# <title>Exam Data Analysis Goals Generator</title>
|
687 |
+
# <script src="https://d3js.org/d3.v7.min.js"></script>
|
688 |
+
# <style>
|
689 |
+
# #visualization { width: 100%; height: 600px; border: 1px solid #ccc; }
|
690 |
+
# #generatedGoals { margin-top: 20px; padding: 10px; border: 1px solid #ccc; }
|
691 |
+
# </style>
|
692 |
+
# </head>
|
693 |
+
# <body>
|
694 |
+
# <h1>Exam Data Analysis Goals Generator</h1>
|
695 |
+
# <div id="visualization"></div>
|
696 |
+
# <div id="generatedGoals"></div>
|
697 |
+
# <script>
|
698 |
+
# const width = 1200;
|
699 |
+
# const height = 800;
|
700 |
+
# const goals = [
|
701 |
+
# { id: 1, x: 100, y: 400, name: "Automate Data Import", description: "Develop scripts to automate exam data extraction from various sources (CSV, Excel, databases) using Pandas read_* functions." },
|
702 |
+
# { id: 2, x: 200, y: 300, name: "Data Cleaning", description: "Implement robust data cleaning processes to handle missing values, outliers, and inconsistencies in exam data using Pandas methods like dropna(), fillna(), and apply()." },
|
703 |
+
# { id: 3, x: 300, y: 200, name: "Data Transformation", description: "Utilize Pandas for complex data transformations such as pivoting exam results, melting question-wise scores, and creating derived features for analysis." },
|
704 |
+
# { id: 4, x: 400, y: 300, name: "Statistical Analysis", description: "Develop functions to automate statistical analysis of exam results, including descriptive statistics, hypothesis testing, and correlation analysis using Pandas and SciPy." },
|
705 |
+
# { id: 5, x: 500, y: 400, name: "Performance Metrics", description: "Create custom functions to calculate industry-standard exam performance metrics like item difficulty, discrimination index, and reliability coefficients using Pandas operations." },
|
706 |
+
# // Add more goals here...
|
707 |
+
# ];
|
708 |
+
# const connections = [
|
709 |
+
# { source: 1, target: 2 },
|
710 |
+
# { source: 2, target: 3 },
|
711 |
+
# { source: 3, target: 4 },
|
712 |
+
# { source: 4, target: 5 },
|
713 |
+
# // Add more connections here...
|
714 |
+
# ];
|
715 |
+
# const svg = d3.select("#visualization")
|
716 |
+
# .append("svg")
|
717 |
+
# .attr("width", width)
|
718 |
+
# .attr("height", height);
|
719 |
+
# const simulation = d3.forceSimulation(goals)
|
720 |
+
# .force("link", d3.forceLink(connections).id(d => d.id))
|
721 |
+
# .force("charge", d3.forceManyBody().strength(-400))
|
722 |
+
# .force("center", d3.forceCenter(width / 2, height / 2));
|
723 |
+
# const link = svg.append("g")
|
724 |
+
# .selectAll("line")
|
725 |
+
# .data(connections)
|
726 |
+
# .enter().append("line")
|
727 |
+
# .attr("stroke", "#999")
|
728 |
+
# .attr("stroke-opacity", 0.6);
|
729 |
+
# const node = svg.append("g")
|
730 |
+
# .selectAll("circle")
|
731 |
+
# .data(goals)
|
732 |
+
# .enter().append("circle")
|
733 |
+
# .attr("r", 10)
|
734 |
+
# .attr("fill", d => d.color || "#69b3a2")
|
735 |
+
# .call(d3.drag()
|
736 |
+
# .on("start", dragstarted)
|
737 |
+
# .on("drag", dragged)
|
738 |
+
# .on("end", dragended));
|
739 |
+
# const text = svg.append("g")
|
740 |
+
# .selectAll("text")
|
741 |
+
# .data(goals)
|
742 |
+
# .enter().append("text")
|
743 |
+
# .text(d => d.name)
|
744 |
+
# .attr("font-size", "12px")
|
745 |
+
# .attr("dx", 12)
|
746 |
+
# .attr("dy", 4);
|
747 |
+
# node.on("click", async function(event, d) {
|
748 |
+
# const response = await fetch('/generate_goals', {
|
749 |
+
# method: 'POST',
|
750 |
+
# headers: { 'Content-Type': 'application/json' },
|
751 |
+
# body: JSON.stringify({ input_var: d.name })
|
752 |
+
# });
|
753 |
+
# const data = await response.json();
|
754 |
+
# document.getElementById("generatedGoals").innerHTML = `<h2>Generated Goals for ${d.name}</h2><pre>${data.goals}</pre>`;
|
755 |
+
# });
|
756 |
+
# simulation.on("tick", () => {
|
757 |
+
# link
|
758 |
+
# .attr("x1", d => d.source.x)
|
759 |
+
# .attr("y1", d => d.source.y)
|
760 |
+
# .attr("x2", d => d.target.x)
|
761 |
+
# .attr("y2", d => d.target.y);
|
762 |
+
# node
|
763 |
+
# .attr("cx", d => d.x)
|
764 |
+
# .attr("cy", d => d.y);
|
765 |
+
# text
|
766 |
+
# .attr("x", d => d.x)
|
767 |
+
# .attr("y", d => d.y);
|
768 |
+
# });
|
769 |
+
# function dragstarted(event) {
|
770 |
+
# if (!event.active) simulation.alphaTarget(0.3).restart();
|
771 |
+
# event.subject.fx = event.subject.x;
|
772 |
+
# event.subject.fy = event.subject.y;
|
773 |
+
# }
|
774 |
+
# function dragged(event) {
|
775 |
+
# event.subject.fx = event.x;
|
776 |
+
# event.subject.fy = event.y;
|
777 |
+
# }
|
778 |
+
# function dragended(event) {
|
779 |
+
# if (!event.active) simulation.alphaTarget(0);
|
780 |
+
# event.subject.fx = null;
|
781 |
+
# event.subject.fy = null;
|
782 |
+
# }
|
783 |
+
# </script>
|
784 |
+
# </body>
|
785 |
+
# </html>
|
786 |
+
# """
|
787 |
+
|
788 |
+
# class MyHandler(SimpleHTTPRequestHandler):
|
789 |
+
# def do_GET(self):
|
790 |
+
# self.send_response(200)
|
791 |
+
# self.send_header('Content-type', 'text/html')
|
792 |
+
# self.end_headers()
|
793 |
+
# self.wfile.write(html_content.encode())
|
794 |
+
|
795 |
+
# def do_POST(self):
|
796 |
+
# if self.path == '/generate_goals':
|
797 |
+
# try:
|
798 |
+
# content_length = int(self.headers['Content-Length'])
|
799 |
+
# post_data = self.rfile.read(content_length)
|
800 |
+
# data = json.loads(post_data.decode('utf-8'))
|
801 |
+
# input_var = data['input_var']
|
802 |
+
# goals = generate_goals(input_var)
|
803 |
+
|
804 |
+
# response = json.dumps({'goals': goals}).encode()
|
805 |
+
# self.send_response(200)
|
806 |
+
# self.send_header('Content-type', 'application/json')
|
807 |
+
# self.send_header('Content-Length', str(len(response)))
|
808 |
+
# self.end_headers()
|
809 |
+
# self.wfile.write(response)
|
810 |
+
# except Exception as e:
|
811 |
+
# logging.error(f"Error handling POST request: {str(e)}")
|
812 |
+
# self.send_error(500, f"Internal server error: {str(e)}")
|
813 |
+
# else:
|
814 |
+
# self.send_error(404)
|
815 |
+
|
816 |
+
# def run_server(port):
|
817 |
+
# try:
|
818 |
+
# server = ThreadingHTTPServer(('0.0.0.0', port), MyHandler)
|
819 |
+
# print(f"Server running on port {port}")
|
820 |
+
# server.serve_forever()
|
821 |
+
# except Exception as e:
|
822 |
+
# logging.error(f"Error running server: {str(e)}")
|
823 |
+
# traceback.print_exc()
|
824 |
+
|
825 |
+
# if __name__ == '__main__':
|
826 |
+
# port = int(os.environ.get("PORT", 7860))
|
827 |
+
# run_server(port)
|