repl.it
@paulfears/

ONLINE TEXT MESSAGES-1

Django

this web app allows you to send text messages

fork
loading
Files
  • main
    • views.py
    • __pycache__
    • migrations
    • models.py
    • settings.py
    • urls.py
  • static
  • templates
  • db.sqlite3
  • db.sqlite3-journal
main/views.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
from django.shortcuts import render


# Create your views here.
def home(request):
    return render(request, 'main/index.html')

def sms(request):
  from django.http import HttpResponse
  import requests
  number = request.POST.get('number', '')
  
  def send_sms(phonenum):
    def get_email(number):
      session = requests.Session()
      print("number is",number)
      data = {"phonenum":str(number),'cc':str(1),'test':str(456)}
      headers = {'Origin': 'https://freecarrierlookup.com','Referer': 'https://freecarrierlookup.com/','Host': 'freecarrierlookup.com'}
      session.get('https://freecarrierlookup.com/')
      
      r = session.post("https://freecarrierlookup.com/getcarrier.php", data=data, headers=headers)
      print(r.text)
      if('Invalid phone number' in r.text):
        return False
      a =  str(number)+'@'+r.text.split("@")[1].split("<\/p>")[0]
      print(a)
      return a
    return get_email(phonenum)
  return HttpResponse(send_sms(number))