Info Security Memo
  • Blog
  • Sitemap
    • Categories
  • Contact
  • About
  • Resources
  • Tools
  • 51sec.org

Build Confidence

Focusing on Information Security 

Info Security Notes

Deploy A Python App Free into Cloud to Show Visitor's Public IP

5/17/2021

0 Comments

 
Deploy A Python App Free into Cloud to Show Visitor's Public IP

It is pretty easy to deploy a simple serverless script into cloud. Following three vendors are providing a free service for that"

  • Heroku - is a platform that lets developers deploy, manage, scale web apps. It provides its own CLI which lets you use your terminal to track changes or deploy your code directly to Heroku after logging in.
  • Netlify -  is a saas platform to build, deploy and host your static site or app with a drag and drop interface and automatic delpoys from GitHub or Bitbucket. Netlify is smart enough to process your site and make sure all assets gets optimized and served with perfect caching-headers from a cookie-less domain. 
  • Vercel - is also a platform to deploy and manage your web apps but the front-end part only. Though the steps are very easy. You just need to connect your Github account with Vercel and then choose the repository which has the project you wish to deploy. Once added, it will also keep track of any changes you’ll do in your master branch and will keep re-deploying the app with those changes.

In this post, I am going to use Vercel as the platform to run my small Python web app to show the visitor's public ip.
What you will need is only a Github account and a Vercel account. 

Create a Python script at GitHub

Here are steps to create your own Github repository, folder structure and file you will need:
  1. Log into Github account
  2. Create repository
  3. Create folder , api
  4. Create a file and name it as index.py
Or, you can direct folk my project from https://ift.tt/2STpdRP o your account





from http.server import BaseHTTPRequestHandler
class handler(BaseHTTPRequestHandler):
  def do_GET(self):
    self.send_response(200)
    self.end_headers()
    self.wfile.write(self.headers.get('x-forwarded-for').encode())
    return



Create Your Vercel Account and Deploy Github project

Here are steps to deploy the Github myip project:
  1. Log into your Vercel account
  2. Connect it with your Github account
  3. Import myip project
  4. Once deployed, visit app using Vercel's links which it will be emailed to you.
  5. You can add your own domain as well 





Add Your Own Domain for Vercel Project

You can also add your own domain into your project. You will get invalid configuration errors if you did not set up cname record or a record firstL

Cloudflare configuration, Proxy Status has to be DNS Only:



Now we can get this app working by browsing to https://ift.tt/2QpSGlt


The reason for api folder is to let Vercel python to run your script at api page. Basically "the only requirement is to create an api directory at the root of your project directory, placing your Serverless Functions inside" based on Vercel documentation. 





via Blogger https://ift.tt/3fnL9w9
May 17, 2021 at 04:27PM Python
0 Comments



Leave a Reply.

    Categories

    All
    Architecture
    Blog
    Checkpoint
    Cisco
    Cloud
    CyberArk
    F5
    Fortigate
    Guardium
    Juniper
    Linux
    Network
    Others
    Palo Alto
    Qualys
    Raspberry Pi
    Security
    SIEM
    Software
    Vmware
    VPN
    Wireless

    Archives

    March 2024
    February 2024
    January 2024
    December 2023
    November 2023
    October 2023
    September 2023
    August 2023
    July 2023
    June 2023
    May 2023
    April 2023
    March 2023
    February 2023
    January 2023
    December 2022
    November 2022
    October 2022
    September 2022
    August 2022
    July 2022
    June 2022
    May 2022
    April 2022
    March 2022
    February 2022
    January 2022
    December 2021
    November 2021
    October 2021
    September 2021
    August 2021
    July 2021
    June 2021
    May 2021
    April 2021
    March 2021
    February 2021
    January 2021
    December 2020
    November 2020
    October 2020
    September 2020
    August 2020
    July 2020
    October 2019
    September 2019
    June 2019
    July 2018
    May 2018
    December 2017
    August 2017
    April 2017
    March 2017
    January 2017
    December 2016
    November 2016
    October 2016
    September 2016
    August 2016
    July 2016
    June 2016
    May 2016
    April 2016
    March 2016
    February 2016
    January 2016
    December 2015
    November 2015
    October 2015
    September 2015
    August 2015
    July 2015
    June 2015
    May 2015
    April 2015
    March 2015

    Print Page:

    RSS Feed

    Email Subscribe
Powered by Create your own unique website with customizable templates.
  • Blog
  • Sitemap
    • Categories
  • Contact
  • About
  • Resources
  • Tools
  • 51sec.org