Stack Exchange
MissingSchema: Invalid URL 'None': No schema supplied. Perhaps you meant http://None?
views.py
from django.shortcuts import render
from django.http import HttpResponse
import random
import hashlib
import os
import requests

def index(request):
 """Displays the page that asks for the phone number"""
 return render(request, "verify/sms.html")

def verify(request):
 """Displays the page that asks for the verification code"""
 # if the form wasn't submitted properly, then go to index page
 try:
    phoneNumber = request.POST['phonenumber']
 except:
    return render(request, "verify/sms.html")

 verificationCode = str(random.randint(1000000, 9999999))

# the check sequence is sent to the next page to verify if the code entered is correct
 checkSequence = hashlib.sha1((verificationCode+str(os.environ.get("SEED"))).encode("utf-8")).hexdigest()

 sendVerificationCode(phoneNumber, verificationCode)
 return render(request, "verify/verification.html", {"code": checkSequence})

def checkCode(request):
"""Checks if the verification code entered is correct"""
 try:
    verificationCode = request.GET['verification']
    correctCheckSequence = request.GET['code']
 except:
    return render(request, "verify/sms.html")

# check the correct check sequence against the check sequence based on the verification code provided
 checkSequence = hashlib.sha1((verificationCode+str(os.environ.get("SEED"))).encode("utf-8")).hexdigest()
 if checkSequence == correctCheckSequence:
    return HttpResponse("1")
 else:
    return HttpResponse("0")

def sendVerificationCode(phoneNumber, verificationCode):
"""Sends the verification code to the provided phone number using TILL API"""
 if len(phoneNumber) < 10:
    return              # doesn't give the user an error message - just doesn't send the message

 TILL_URL = os.environ.get("TILL_URL")
requests.post(TILL_URL, json={"phone":[phoneNumber], "text": "Verication code: " + str(verificationCode)})

urls.py
from django.conf.urls import url, include
from . import views

urlpatterns = [
 url(r'^$', views.index, name="index"),
 url(r'^verify/$', views.verify, name="verify"),
 url(r'^checkCode/$', views.checkCode, name="checkCode")
]

models.py
from django.db import models

admin.py
from django.contrib import admin

apps.py
from django.apps import AppConfig


class VerifyConfig(AppConfig):
 name = 'verify'

Creating a sms-validation app.Where a user enters his phone number and message is send to validate his number.
Soon after asking his number and hitting enter it shows error.
raise MissingSchema(error)
MissingSchema: Invalid URL 'None': No schema supplied. Perhaps you meant http://None?
Traceback
Internal Server Error: /verify/
Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-
packages/django/core/handlers/exception.py", line 41, in inner
response = get_response(request)
File "/usr/local/lib/python2.7/dist-
packages/django/core/handlers/base.py", line 187, in _get_response
response = self.process_exception_by_middleware(e, request)
File "/usr/local/lib/python2.7/dist-
packages/django/core/handlers/base.py", line 185, in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/home/tushar/Downloads/sms-verify-master/verify/views.py", line 25, in verify
sendVerificationCode(phoneNumber, verificationCode)
File "/home/tushar/Downloads/sms-verify-master/verify/views.py", line 49, in sendVerificationCode
requests.post(TILL_URL, json={"phone":[phoneNumber], "text": "Verication code: " + str(verificationCode)})
File "/usr/local/lib/python2.7/dist-packages/requests/api.py", line 109, in post
return request('post', url, data=data, json=json, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/requests/api.py", line 50, in request
response = session.request(method=method, url=url, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/requests/sessions.py", line 454, in request
prep = self.prepare_request(req)
File "/usr/local/lib/python2.7/dist-packages/requests/sessions.py", line 388, in prepare_request
hooks=merge_hooks(request.hooks, self.hooks),
File "/usr/local/lib/python2.7/dist-packages/requests/models.py", line 293, in prepare
self.prepare_url(url, params)
File "/usr/local/lib/python2.7/dist-packages/requests/models.py", line 353, in prepare_url
raise MissingSchema(error)
MissingSchema: Invalid URL 'None': No schema supplied. Perhaps you meant http://None?


You should both show the full traceback, and remove the irrelevant parts of your code. However it seems that TILL_URL is None; have you set that environment variable? How?

I have created the account on Till, but which url to copy??

No idea. What's Till?

Is it kind of dangerous to put this code on public? (Assuming that platform.tillmobile.com is a production environment)

TILL_URL is 'None'
Either change this line:
TILL_URL = os.environ.get("TILL_URL")

To:
TILL_URL = "https://platform.tillmobile.com/api/send/?username=<username>&api_key=<api_key>"

or set TILL_URL environment variable in your OS, by export command in linux terminal:
~ export TILL_URL="https://platform.tillmobile.com/api/send/?username=<username>&api_key=<api_key>"

They API http:
https://platform.tillmobile.com/api/send/?username=<username>&api_key=<api_key>

Use your user name and API key from your dashboard, which you get after registering:
https://platform.tillmobile.com/dashboard/

Sir,but which url to copy after creating account on Till??

I believe that you have to have an account registered with Till mobile first and then they will provide it.

Edited my answer, please see.

Sir, it take you to a page where it tells about its services and also shows api-key.

I just googled the provider and looked into it's support forum. I also registered by myself to see if my thoughts are right. :) You are welcome
