Coder Social home page Coder Social logo

python-c's Introduction

Python-C

Note!: This is NOT a PROPER example of HTTP client with sockets in C. Main purpose of this repository is to learn to build python modules with Python C API!

I use Python 3.8.10 and gcc 9.4.0

See code of 'HTTP client' in src/* directory and myhttp.c for Python C extention code.

The 1st step:

Install <Python.h> to be able to include the header in your code:

sudo apt-get install python3-dev

The 2nd step:

Configure localhost:

  1. Open /etc/hosts with any editor and paste this code:
127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4

The 3rd step:

Install MyHttp package

  1. Install the package globally:
sudo python3 setup.py install

Check installation with:

pip3 freeze

You should see this in result your installed modules:

...
MyHttp==1.0.0
...
  1. Or install it locally:
sudo python3 setup.py build

Codes below will create .so file in /build/*/ folder.

4th step:

Test your code:

Note: Before testing with localhost, run server.py (default port is: 8080):

python3 server.py

Run test.py as:

python3 test.py --full-print

As --full-print flag provided test.py will print full responses.


Use --no-external or --no-internal to exclude external or local requests, respectively.

python-c's People

Contributors

giorgiomegrelli avatar jmarvi3 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.