Giter Club home page Giter Club logo

flask-stripe-server's Introduction

Flask Server on AWS EC2 This repository contains a simple Python Flask server that utilizes the Stripe API for handling product information and creating checkout sessions. The server is designed to be hosted on an AWS EC2 instance. Below are instructions for deploying and setting up the server.

Prerequisites AWS account with appropriate permissions to create EC2 instances and security groups. Stripe API key (replace 'sk_......' with your actual Stripe secret key).

Deployment

  1. EC2 Instance Setup:

Use the provided CloudFormation template (cloudformation-template.yaml) to create the necessary AWS resources. This includes an EC2 instance, a security group allowing SSH (port 22) and HTTP (port 80) traffic, and an optional key pair for SSH access.

```bash
aws cloudformation create-stack --stack-name YourStackName --template-body file://cloudformation-template.yaml --parameters ParameterKey=SshIp,ParameterValue=0.0.0.0/0 ParameterKey=ImageId,ParameterValue=ami-0b898040803850657 ParameterKey=InstanceType,ParameterValue=t2.micro
  1. Clone the Repository:

    git clone https://github.com/yourusername/flask-stripe-ec2.git
    cd flask-stripe-ec2
    
  2. Install Dependencies:

    pip install -r requirements.txt
    
  3. Configure Stripe API Key: Replace 'sk_......' in app.py with your actual Stripe secret key.

    stripe.api_key = 'your_stripe_secret_key'

  4. Run the Flask Server:

    python3 app.py
    

Usage

Access the products endpoint: http://your-ec2-instance-ip:5000/ Create a checkout session: Send a POST request to http://your-ec2-instance-ip:5000/create-checkout-session with a JSON payload containing line items.

Cleanup To delete the resources created by the CloudFormation stack:

```bash
aws cloudformation delete-stack --stack-name YourStackName

Additional Notes Ensure your security group allows traffic on port 80 for HTTP access. Uncomment the corresponding lines in the CloudFormation template if you want to enable HTTPS. Customize the success and cancel URLs in app.py to match your application's flow. Make sure to secure your EC2 instance properly, and consider using a web server (e.g., Nginx) in production for better performance and security.

flask-stripe-server's People

Contributors

deenovee avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.